Sort Characters By Frequency — LeetCode 451 Max-Heap Pattern
Solve LeetCode 451 Sort Characters By Frequency with a max-heap or bucket sort. A common Amazon and Meta phone-screen on hash + heap composition.
1582 articles
Solve LeetCode 451 Sort Characters By Frequency with a max-heap or bucket sort. A common Amazon and Meta phone-screen on hash + heap composition.
Solve LeetCode 973 K Closest Points to Origin using a max-heap (O(n log k)) or Quickselect (O(n) average). One of the most-asked Meta and Amazon problems.
Solve LeetCode 621 Task Scheduler with a max-heap + cooldown queue or a closed-form math formula. A favorite Amazon and Meta scheduling interview.
Solve LeetCode 767 Reorganize String with a max-heap by always picking the two most frequent characters. A staple Amazon, Meta, and Google interview problem.
LeetCode 295 (Hard) — a FAANG favorite. Maintain a dynamic median from a live data stream using two heaps: a max-heap for the lower half and a min-heap for the upper half, achieving O(log n) per insert.