Last Median Standing
CodeChefOpen on judge ↗
You are given an array of integers A of size $2N-1$. In $N-1$ steps, the array will reduce to a single element $X$. Note that the array is a permutation of $(1,2,...,2N-1)$ initially. For each step: (refer to sample) 1) Construct a new array $B$ of size $2$ less than the array $A$ such that B[$i$] is the median of A[$i$], A[$i+1$], A[$i+2$]. Here, $1 \leq i \leq N-2$ (one-based indexing)
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