Design a class KthLargest to find the kth largest element in a stream. The kth largest element is the kth largest element in the sorted order, not the kth distinct element.
Implement KthLargest class:
KthLargest(int k, int[] nums)Initializes the object with the integerkand the stream of integersnums.int add(int val)Appends the integervalto the stream and returns the element representing thekthlargest element in the stream.
- Method calls.
Input: ["KthLargest", "add", "add", "add"] [[3, [4, 5, 8, 2]], [3], [5], [10]]
Output: [null, 4, 5, 5]