Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.

Try one problem
0
Concept

Overview

Take the best local choice, never look back
step 1 / 10
1
5
10
25
[0][1][2][3]
The greedy paradigm
1greedy(problem):
2 solution ← empty
3 while not done:
4 choice ← best LOCAL option right now
5 commit to choice // never reconsidered
6 reduce problem by choice
7 return solution
8// valid only if greedy-choice property + optimal substructure
state
  • coins[1, 5, 10, 25]

line 1A GREEDY algorithm builds an answer one choice at a time, and at every step it commits to whatever looks best RIGHT NOW — the best LOCAL choice — and never looks back. No undo, no exploring alternatives: pick, commit, move on.