Possible Contender
You have an array $A$ of length $N$. You can perform the following operation on it as many times as you like (possibly, zero): - Choose two integers $L$ and $R$ ($1 \leq L \lt R \leq |A|$); - Delete the elements $A_L, A_{L+1}, \ldots, A_R$ from $A$; and - Insert the median$^\dagger$ of $[A_L, A_{L+1}, \ldots, A_R]$ in their place. Here, $|A|$ denotes the length of $A$. Note that this length red
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