Practice
Learn
← Quit
0 / 0 correct
Algorithms
Medium
1 of 30
What is an efficient way to keep the k largest elements from a stream of n numbers?
A
Sort everything at the end: O(n log n) time, O(n) memory
B
A hash map of counts
C
A min-heap of size k: O(n log k) time, O(k) memory
D
A max-heap of all elements: O(n) memory