solve(nums, k) — return the k-th largest value of nums (1-based, duplicates
count: in [7,7,7] the 2nd largest is 7). Do not modify the input array.
Sorting costs O(n log n) and a heap O(n log k). Quickselect reaches O(n) on average:
partition around a pivot like quicksort, but recurse into only the side that contains
the target position. The k-th largest sits at index n - k of the sorted array. A
three-way partition (smaller / equal / larger, the same pointer dance as Sort Colors)
keeps duplicates from degrading it.
Examples
solve([3,2,1,5,6,4], 2) → 5
solve([3,2,3,1,2,4,5,5,6], 4) → 4
solve([7,7,7], 2) → 7Sample tests