educative.io

Why not check if the incoming number is greater than minHeap.peek() before pop()?

I think, this condition is buggy.

    if (this.minHeap.length > this.k) {
      this.minHeap.pop();
    }

if number is less than minHeap.peek() we are not going to get the kth largest in that case, right?

1 Like

Will look into the solution. There are a few issues with the solution provided.