Skip to content

Glossary: Coding Interviews in C++

Greedy

Also written: greedy algorithm

Taking the best-looking choice at each step. It works for only some problems; for bags of 2, 5 and 6 lb it fails to find the fewest bags for 13 lb.

Where the book teaches it

Related terms

Dynamic programming (DP)Topological sortUnion-find