Greedy
Builds the solution step by step by always choosing the best option available.
[1, 4]
[3, 5]
[0, 6]
[5, 7]
[8, 9]
[5, 9]
Sort intervals by end time.
Where It's Used
- Problems where a locally optimal choice leads to the correct final solution.
- Scheduling or interval selection problems.
- Selecting items under constraints.
- Building optimal results step by step without backtracking.
Problems Using This Pattern
Merge Intervals
Greedy + Sorting
Maximum Subarray
Greedy
Jump Game
Greedy
Gas Station
Greedy
Partition Labels
Greedy
Non Overlapping Intervals
Greedy