WORLD 7
GREEDY
Take the best move right now and never look back, when you can prove that's safe: jumps, a road trip, a packed stage.
STAGE 0 Greedy tutorial
0:00 / 0:00
The move
Take what looks best right now and never go back. It only works when today's best pick can't hurt you later, so the skill is spotting when that's safe. Often you sort first, or track one value such as the farthest reach.
- Spot it
- Minimum number of, maximum you can, intervals, or can you reach, where swapping in the greedy pick never makes things worse.
- Cost
- Usually one pass: O(n) time, or O(n log n) with a sort.
16 STAGES Greedy problems
☆☆☆☆☆ Clear 5 to finish this world.
EASY1:35Can Place Flowers
GreedyLC 605▶ START
MEDIUM1:35Jump Game
GreedyLC 55▶ START
MEDIUM1:37Jump Game II
GreedyLC 45▶ START
MEDIUM1:44Gas Station
GreedyLC 134▶ START
HARD1:41Candy
GreedyLC 135▶ START
MEDIUM1:38Non-overlapping Intervals
GreedyLC 435▶ START
MEDIUM1:37Minimum Number of Arrows to Burst Balloons
GreedyLC 452▶ START
MEDIUM1:32Partition Labels
GreedyLC 763▶ START
MEDIUM1:43Boats to Save People
GreedyLC 881▶ START
MEDIUM1:41Remove K Digits
GreedyLC 402▶ START
MEDIUM1:36Two City Scheduling
GreedyLC 1029▶ START
MEDIUM1:43Valid Parenthesis String
Greedy rangeLC 678▶ START
MEDIUM1:45Maximum Subarray
GreedyLC 53▶ START
MEDIUM1:44Hand of Straights
GreedyLC 846▶ START
MEDIUM1:44Task Scheduler
GreedyLC 621▶ START
MEDIUM1:36Merge Triplets to Form Target Triplet
GreedyLC 1899▶ START