← All problemsSign in

C - Check Good

An array $B$ of length $M$ is considered **good** if there exists a permutation $P$ of $[1, 2, \ldots, M]$ such that for every $i$ $(1 \leq i \leq M)$, the following condition holds: $$ B_i = \max(P_1, P_2, \ldots, P_i) - \min(P_1, P_2, \ldots, P_i) $$ You are given an array $A$ of length $N$. For each integer $i$ $(1 \leq i \leq N)$, determine whether there exists a **subarray**$^{\dagger}$ $

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start