All lessons

Greedy Algorithms

7 min · OCaml examples

Make the locally best choice at each step when that strategy is safe.

OCaml · Greedy Algorithms0/5 cleared

Enemy 1 of 5

Greedy algorithms pick the best-looking option right now without backtracking. They work when a local optimum leads to a global optimum — like giving the largest coin first in change-making with standard denominations.

You
Goblin Glitch

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: 4