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