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.

  1. Find M Smallest ElementsPractice · +10 XPeasy
  2. Find Smallest and Largest ElementsPractice · +10 XPeasy
  3. K-th Largest ElementPractice · +10 XPeasy
  4. Print Largest N IntegersPractice · +10 XPeasy
  5. Print Last K ElementsPractice · +10 XPeasy
  6. Smallest Element After RemovalsPractice · +10 XPeasy
  7. Sum of First K ElementsPractice · +10 XPeasy
  8. Top K Smallest ElementsPractice · +10 XPeasy
  9. Top Three ScoresPractice · +10 XPeasy
  10. Distinct Element Sum with Minimum CostPractice · +20 XPmedium
  11. Distinct Elements with Minimum Total CostPractice · +20 XPmedium
  12. Find K Distinct Element FrequenciesPractice · +20 XPmedium
  13. Find K Smallest Distinct ElementsPractice · +20 XPmedium
  14. Find Minimums in Sliding WindowsPractice · +20 XPmedium
  15. Maximize Distinct Elements After OperationsPractice · +20 XPmedium
  16. Merge K Sorted ListsPractice · +20 XPmedium
  17. Process Tasks by DeadlinePractice · +20 XPmedium
  18. Minimize Maximum Difference of Elements in IntervalsPractice · +30 XPhard