Permutation Reduction
CodeChefOpen on judge ↗
Given an array $A$ of length $M$, consider the following operation: - Choose an index $i$ ($1 \lt i \lt M$) such that $A_i \gt A_{i-1}$ **and** $A_i \gt A_{i+1}$. - Then, delete $\max(A_{i+1}, A_{i-1})$ from $A$. Note that this reduces the length of $A$ by $1$. For example, if $A = [1, 3, 2, 5, 4]$, you can perform the operation with $i = 2$ or $i = 4$, which result in the arrays $[1, 3, 5, 4]$
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