Prefix Ones
Chef has a binary string $S$ of length $N$. Chef can perform the following operation on the string: - Choose any substring of $S$; - Remove the chosen substring from $S$; - Concatenate the remaining parts of the string $S$, obtained after removing the substring. Find the length of the longest prefix having **all** $1$s you can achieve, by performing the above operation **at most** once. Note: A
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