#703

Kth Largest Element in a Stream

easy· Heap / Priority Queueruns: 0

Design a class that finds the kth largest element in a stream. Implement KthLargest(k, nums) which initializes the class with the integer k and the stream nums, and add(val) which appends val to the stream and returns the kth largest element seen so far.

sign in to paste and practice your own solution
desktop only

codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.

you can still browse problems and sections from your phone.