Problem context and objectives
Mission briefing
Clockwork game engineer · A tournament scoreboard has jammed
Restore the order before the next round begins: Distance Dials.
A wrong ordering changes who advances, while a slow repair freezes every active match.
How you win
- 1Recognize when Custom comparator matches the clues
- 2Keep this true after every move: earlier values have a smaller distance key or a smaller tie value
- 3Reach the result within O(n log n)
Rules and pressure
- Target cost: O(n log n)
- State rule: earlier values have a smaller distance key or a smaller tie value
Lesson 1 of 3
Give each value a tuple key: absolute distance from the pivot first, then the value itself as tie-break.
Your call · At pivot 4, what is the key for value 7?