Heaps and lazy deletion; ordered-set substitutes
- Stage
- 5
- Module
- M5.11
- Lessons
- 1
In this module
- Implement min-heaps and max-heaps using heapq and negation.
- Detect and skip out-of-date entries using validity checks.
- Simulate multiset operations and keep running aggregates.
- Maintain a sliding window minimum using a lazy-deletion deque.
Before this module
Lessons
Practice
Try these on the judge. Each link opens the problem on WMOJ.
- 2021 S4Daily Commute (opens on WMOJ in a new tab) WMOJ
Find the minimum of dynamic expressions using lazy-deletion heaps to track candidates.
- 2025 S3Pretty Pens (opens on WMOJ in a new tab) WMOJ
Track the best combination of items in a changing collection under updates.
Why DMOJ: A greedy problem over a changing collection, solved with heaps and lazy deletion.