When to Use Greedy

Use greedy when:

1.1. The problem has optimal substructure and greedy choice property

2.2. You can prove that a local optimum leads to a global optimum

3.3. Making a choice doesn't require knowing future inputs

4.4. You can swap a non-greedy choice with a greedy one without worsening the solution

If you can't sketch a proof, consider DP instead. Greedy that works by accident fails on edge cases.