10. Heaps
🧠Strategy
- Heaps (Priority Queue):
- Kth Largest/Smallest: Use a Heap of size K. (Min-Heap for largest, Max-Heap for smallest).
- Stream Data: Use two heaps (Min & Max) for Running Median.
- Merge K Sorted: Push the first element of all K arrays into a Min-Heap.
- Greedy:
- Sorting is Key: Most greedy problems start by sorting the data (Start Times, Costs, etc.).
- Local Optimal: Make the best choice right now (e.g., pick the job ending earliest).
🟢 Heap Basics
- Connect Ropes
- Magician And Chocolates
- Product Of 3
- Maximum Array Sum After B Negations
- Misha And Candies
- B Closest Points To Origin
- The Ship Company
🟡 Kth Element & Streams
- Running Median
- Ath Largest Element
- N Max Pair Combinations
- K Places Apart
- Kth Smallest Element In A Sorted Matrix
- Bth Smallest Prime Fraction
- Special Median
- Minimum Largest Element
🟠Greedy Algorithms
- Finish Maximum Jobs
- Distribute Candy
- Flipkart Challenge Inventory Management
- Assign Mice To Holes
- Seats
- Binary Strings
- Another Coin Problem