When to Use

Pattern triggers

Look for these signals in the problem:

  • "Maximum/minimum" with selection constraints: When choosing elements one at a time, greedy picks the best available.
  • "Interval scheduling": Selecting non-overlapping intervals often has greedy solutions.
  • "Assign resources" to tasks: Greedy assignment by some priority (deadline, profit) often optimal.
  • "Reach farthest": Jump games and coverage problems use greedy extension.
  • Exchange argument works: If swapping any choice with greedy choice doesn't improve solution, greedy is optimal.