22. Greedy

Intervals, jump game, gas station and exchange arguments.

🎬 Episodes 69–73: video coming soon
Your progress0 of 14
3easy
10medium
1hard

Understand the topic

A greedy algorithm makes the best-looking choice at each step and never goes back. It's fast and simple, but it's only correct when you can argue that the local choice never blocks a better overall answer. If you can't make that argument, use dynamic programming.

The classic greedy choices: sort intervals by end time and keep the one that finishes first (activity selection); take the best value per unit first (fractional knapsack); track the furthest reach (jump game); reset the start when your running balance goes negative (gas station).

#ProblemPatternLevel
1 Assign Cookies #455 Sort + match smallest Easy LeetCode β†—
2 Lemonade Change #860 Greedy change-making Easy LeetCode β†—
3 Maximum Units on a Truck #1710 Fractional-knapsack style Easy LeetCode β†—
4 Best Time to Buy and Sell Stock II #122 Collect every rise Medium LeetCode β†—
5 Jump Game #55 Furthest reach Medium LeetCode β†—
6 Jump Game II #45 BFS by ranges Medium LeetCode β†—
7 Gas Station #134 Reset start on deficit Medium LeetCode β†—
8 Non-overlapping Intervals #435 Sort by end (activity selection) Medium LeetCode β†—
9 Minimum Number of Arrows to Burst Balloons #452 Sort by end Medium LeetCode β†—
10 Insert Interval #57 Three phases Medium LeetCode β†—
11 Partition Labels #763 Last occurrence Medium LeetCode β†—
12 Valid Parenthesis String #678 Range of open counts Medium LeetCode β†—
13 Hand of Straights #846 Smallest card starts a group Medium LeetCode β†—
14 Candy #135 Two passes Hard LeetCode β†—

Work top to bottom β€” each list goes from easy to hard. Try a problem for at least 15 minutes before opening a hint. Ticks are saved in your browser.