Subarray Maximums
You are given a **binary** string $S$ of length $N$. Your task is to find any permutation$^\dagger$ $P$ of $[1, N]$ that satisfies the following conditions: - For each index $i$ ($1 \le i \le N$), - If $S_i = 1$, there exists a contiguous subarray of $P$ having length $i$ whose maximum element is $i$. More formally, there must exist a pair of integers $(L, R)$ such that $1 \le L \le R \le
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