Heaps and Priority Queues
82 / 170Heaps and Priority QueuesLesson 2 of 8About 51 min
The counterintuitive one: to track the k largest, keep a heap of the smallest of them.
You must maintain the k smallest values from an ongoing stream. What kind of heap should hold them, and what sits at its top?
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.
Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.