text class KthLargest: function constructor(k, nums): this.k = k this.minHeap = new MinHeap() for num in nums: this.add(num) function add(val): this.minHeap.push(val) if this.minHeap.size() > this.k: this.minHeap.pop() return this.minHeap.top() Time complexity: per add operation. Space complexity: for the heap.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/heaps-priority-queues/kth-largest-stream-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████████████████████████████████████████████████████████████████████████████████████████████