Greedy Algorithms8 sections · 316 units
Open in Course

When Greedy Gets Tricky

Pitfalls to watch

Advanced greedy problems often have subtle traps:

1.1. Tiebreaking matters.: In some problems, how you break ties changes the answer.

2.2. Greedy criterion depends on subproblem.: Create Maximum Number uses different greedy criteria at different stages.

3.3. Proof is not obvious.: Patching Array's doubling insight requires careful analysis.

4.4. Combine multiple techniques.: Some problems need greedy + heap + sorting together. If a greedy solution feels too simple, test edge cases carefully. The devil is in the details.