Problem
Build a class KthLargest that watches a stream of test scores and always knows the `k`th largest score so far. Duplicates count separately.
- KthLargest(k, nums) starts with k and an initial list of scores (possibly empty).
- add(val) adds one score and returns the kth largest value in the stream after adding it.
Example 1
kl = KthLargest(3, [4, 5, 8, 2])
Example 2
- Input
- kl.add(3)
- Output
- 4
Example 3
- Input
- kl.add(5)
- Output
- 5
Example 4
- Input
- kl.add(10)
- Output
- 5
Example 5
- Input
- kl.add(9)
- Output
- 8
Example 6
- Input
- kl.add(4)
- Output
- 8
Constraints
1 <= k <= 10^40 <= nums.length <= 10^4-10^4 <= val <= 10^4At most 10^4 calls to add.Whenever add returns, the stream holds at least k values.