LC 215 — Problem

Given an integer array nums and an integer k, return the k-th largest element in the array. Note that it is the k-th largest element in sorted order, not the k-th distinct element.

Input: nums = 321564, k = 2
Output: 5
Input: nums = 323124556, k = 4
Output: 4

Constraints: 1 ≤ k ≤ nums.length ≤ 10^5 · −10^4 ≤ nums[i] ≤ 10^4 · must outperform the obvious `sort` baseline.

Phase 1: Sort is overkill

A static array 73918210465 and k = 3. Your first instinct: sort everything. Tap the button. Watch exactly HOW MUCH of that sorted answer you actually read.

7
3
9
1
8
2
10
4
6
5