Back to the Problem
Sort and index — or use nth_element / quickselect for O(N) average.
Complexity: O(N log N)