Greedy Practice Questions
Eight interview classics covering every greedy shape you’re likely to see: sort-and-pick, two pointers on sorted input, prefix tracking, interval merging, and bounded simulation. Each one is the unified greedy template with a different sort key or scan rule.
Before reading the solution, ask:
- What’s the greedy strategy? (Often: a sort criterion + a per-item rule.)
- Can I sketch an exchange-argument proof?
- Can I construct a counter-example? If yes, the greedy is wrong — switch to DP.
Three questions, one template, eight problems.
Easy
| Problem | Pattern | Status |
|---|---|---|
| Assign Cookies | Sort both + two pointers | Available |
| Lemonade Change | Bounded simulation with greedy bills | Available |
| Best Time to Buy and Sell Stock II | Sum positive deltas | Available |
Medium
| Problem | Pattern | Status |
|---|---|---|
| Jump Game | Max-reach prefix scan | Available |
| Jump Game II | BFS-flavored greedy intervals | Available |
| Gas Station | Reset on negative running tank | Available |
| Non-overlapping Intervals | Sort by end + count keepers | Available |
| Partition Labels | Last-occurrence prefix scan | Available |
More Practice (Coming Soon)
| Problem | Pattern | Status |
|---|---|---|
| Minimum Number of Arrows to Burst Balloons | Sort by end + sweep | Coming Soon |
| Task Scheduler | Max-heap by frequency | Already on Day 7 |
| Reorganize String | Max-heap by frequency | Already on Day 7 |
| Queue Reconstruction by Height | Sort then insert | Coming Soon |
| Candy | Two-pass left-right scan | Coming Soon |
| Boats to Save People | Sort + two pointers | Coming Soon |
| Minimum Number of Refueling Stops | Greedy with max-heap (hybrid) | Coming Soon |
| IPO / Maximum Capital | Two-heap greedy | Coming Soon |
| Furthest Building You Can Reach | Min-heap of ladder costs | Coming Soon |
| Wiggle Subsequence | Sign-change scan | Coming Soon |