DSA Master › Topic 15

Greedy Algorithms

A greedy algorithm makes the locally best choice at each step and never revisits it. It works only when you can argue that the local choice never hurts the global answer, usually with an exchange argument. When greedy breaks, the problem is often DP.

Concepts

How to recognise it

Common pitfalls

Problems

  1. Jump Game (Medium)
  2. Jump Game II (Medium)
  3. Gas Station (Medium)
  4. Maximum Units on a Truck (Easy)
  5. Partition Labels (Medium)
  6. Candy (Hard)
  7. Hand of Straights (Medium)
  8. Maximum Length of Pair Chain (Medium)