0Pricing
Competitive Programming Academy · Lesson

Spot When Greedy Fails

Find counterexamples before trusting it.

Greedy Is Tempting

Greedy is short, fast, and feels obvious, which is exactly why it can trap you. A clean idea is not the same as a correct one. ⚠️

The Coin Change Trap

With coins 1, 3, and 4, making 6 greedily picks 4 then needs two 1s, totaling three coins. The real best is two 3s.

All lessons in this course

  1. The Greedy Mindset
  2. Activity Selection by Earliest Finish
  3. Fractional Knapsack by Ratio
  4. Spot When Greedy Fails
← Back to Competitive Programming Academy