CodeMosa
Master LeetCode Patterns
All Patterns
Collections
Sign In
Back
Priority Queue (Heap)
Question 1 of 12
8% Complete
Medium
To find the kth largest element in a stream, what's the most efficient approach?
A
Maintain a min heap of size k; the root is the kth largest
B
Maintain a max heap of all elements
C
Sort the array after each insertion
D
Use quickselect on each query
Need a hint?
Think about maintaining a fixed-size collection