k-th Largest Element in a stream

k-th Largest Element in a stream

In this article, we will discuss the problem K-th largest Element in a stream, and understand the different methods that can be used to solve the problem efficiently.

Table of content:

Problem StatementApproach 1: Sorting the ArrayApproach 2: Using min-heap

We will dive into the problem now.

Problem Statement

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.

Implement KthLargest class:

KthLa...
 •  0 comments  •  flag
Share on Twitter
Published on August 24, 2021 09:17
No comments have been added yet.