Greedy Algorithms8 sections · 316 units
Open in Course

Advanced Greedy Patterns

Common themes

You have now seen several advanced greedy problems. Common patterns:

1.1. Monotonic stack:: Remove K digits, Create Maximum Number. Use a stack to maintain some order property.

2.2. Range extension:: Patching Array. Track what you can achieve, greedily extend.

3.3. Simulation with greedy phases:: Candy Crush. Apply greedy logic at each step of a simulation.

4.4. Transformation to known problem:: Arrows to Activity Selection. Recognize a familiar problem in disguise.

5.5. Sort and process:: Make Unique. Sorting reveals structure that enables greedy.