How it works
When greedy works
It needs the greedy-choice property, where a local optimum leads to a global optimum, plus optimal substructure.
Classic examples
Interval scheduling, Huffman coding, and minimum spanning trees are canonical greedy problems.
Greedy vs DP
When greedy choices fail, dynamic programming that explores options is usually required.