A greedy algorithm makes the locally optimal choice at each step, hoping it leads to a global optimum. It is simple and fast, but only correct when the problem has the greedy-choice property and optimal substructure.
The idea
Never reconsider past choices — commit to the best immediate option and move on.
Example: coin change with canonical coins
():
result = []
coin coins:
amount >= coin:
amount -= coin
result.append(coin)
result
greedy_coins()
