Ordered Distances
Chef had a sequence of $N$ **distinct** points $X_1, X_2, ..., X_N$. Chef did the following action to get a new sequence of points $Y$: - Choose a pivot index $i$ ($1 \le i \le N$), and thus a pivot value $P = X_i$. - Make a list $L$ of the $N$ pairs $(|X_j - P|, X_j)$ for each $1 \le j \le N$, i.e. pair of (distance, value). - Sort the list $L$ in increasing order$^{\dagger}$. - Define $Y_k$ as
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