30:00
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.
1≤k≤1041 \leq k \leq 10^41≤k≤104
0≤nums.length≤1040 \leq \text{nums.length} \leq 10^40≤nums.length≤104
−104≤nums[i]≤104-10^4 \leq \text{nums}[i] \leq 10^4−104≤nums[i]≤104
−104≤val≤104-10^4 \leq \text{val} \leq 10^4−104≤val≤104
At most 10410^4104 calls will be made to add.
add
It is guaranteed that there will be at least kkk elements in the array when you call add.
Init K=3, nums=[4,5,8,2]
Empty