P Equal To NP
You are given a string $S$, each character of which is either $\verb+N+$ or $\verb+P+$. In one move, you can perform the following operation: - Pick an index $1 \leq i \leq |S|$ and flip $S_i$, i.e, if $S_i = \verb+N+$ set it to $\verb+P+$ and vice versa. Find the minimum number of moves required to obtain a string such that there exists a way to split it into several continuous substrings, each
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start