Kth Largest Element in a Stream
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.
Kth Largest Element in a Stream

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.

Example 1:
Input: {"commands":["KthLargest","add","add","add","add","add"],"values":[[3,[4,5,8,2]],[3],[5],[10],[9],[4]]}
Output: [null,4,5,5,8,8]
Input
arr ={"commands":["KthLargest","add","add","add","add","add"],"values":[[3,[4,5,8,2]],[3],[5],[10],[9],[4]]}

Init K=3, nums=[4,5,8,2]

Max Heap (Left)

Empty

Min Heap (Right)

Empty

Variables
No variables to display
DepthFunction Call
Stack empty
0/21