Heap and Priority Queue coding problems
Heaps keep the smallest or largest item ready in O(log n): top k elements, merging sorted lists, running medians and scheduling by priority.
18 problems: 9 easy, 8 medium, 1 hard. Free to read; a free account solves them and earns XP and Aura.
- Find M Smallest ElementsPractice · +10 XP · heaps, priority queueseasy
- Find Smallest and Largest ElementsPractice · +10 XP · heaps, min-maxeasy
- K-th Largest ElementPractice · +10 XP · heaps, k-th elementeasy
- Print Largest N IntegersPractice · +10 XP · heaps, priority queues, top-keasy
- Print Last K ElementsPractice · +10 XP · heaps, priority queueseasy
- Smallest Element After RemovalsPractice · +10 XP · heaps, priority queueseasy
- Sum of First K ElementsPractice · +10 XP · heaps, priority queues, k-selectioneasy
- Top K Smallest ElementsPractice · +10 XP · heaps, priority queues, top-keasy
- Top Three ScoresPractice · +10 XP · heaps, sorting, top-keasy
- Distinct Element Sum with Minimum CostPractice · +20 XP · heaps, hash map, greedymedium
- Distinct Elements with Minimum Total CostPractice · +20 XP · heaps, hash set, greedymedium
- Find K Distinct Element FrequenciesPractice · +20 XP · heaps, frequency counting, top-kmedium
- Find K Smallest Distinct ElementsPractice · +20 XP · heaps, priority queues, distinct elementsmedium
- Find Minimums in Sliding WindowsPractice · +20 XP · heaps, sliding window, dequemedium
- Maximize Distinct Elements After OperationsPractice · +20 XP · heaps, greedy, data structuresmedium
- Merge K Sorted ListsPractice · +20 XP · heaps, merging, priority queuesmedium
- Process Tasks by DeadlinePractice · +20 XP · heaps, scheduling, greedymedium
- Minimize Maximum Difference of Elements in IntervalsPractice · +30 XP · heaps, sliding window, greedyhard
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Hash Map and Hashing101Arrays88Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Two Pointers35Stack29Binary Search25Simulation25Recursion22Linked List20Trees20Matrix and Grid18Bit Manipulation18Queue and Deque16