← All problemsSign in

Stable Array

CodeChefRating 1597Open on judge ↗

You're given an array $A$ of length $N$. Every second, the following process will happen: - For each $i$ from $1$ to $N-1$ **in order**, if $A_i \lt A_{i+1}$, set $A_i$ to $A_{i+1}$. For example, if $A = [3, 1, 4, 1, 5]$, the process is as follows: - $A_1$ is not less than $A_2$, so it won't change. - $A_2$ is less than $A_3$, so $A_2$ will be set to $A_3 = 4$. - $A_3$ is not less than $A_4$, s

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