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.
21 STAGES
☆☆☆☆☆ Clear any 5 stages to beat this world, or all 21 for 100%.
EASY2:00Can Place Flowers
GreedyLC 605▶ START
EASY2:07Assign Cookies
GreedyLC 455▶ START
MEDIUM2:04Jump Game
GreedyLC 55▶ START
MEDIUM2:08Jump Game II
GreedyLC 45▶ START
MEDIUM2:08Gas Station
GreedyLC 134▶ START
MEDIUM2:11Minimum Domino Rotations For Equal Row
GreedyLC 1007▶ START
HARD2:02Course Schedule III
GreedyLC 630▶ START
MEDIUM2:06Car Pooling
Prefix sumsLC 1094▶ START
HARD2:07Candy
GreedyLC 135▶ START
MEDIUM2:05Non-overlapping Intervals
GreedyLC 435▶ START
MEDIUM2:10Insert Interval
GreedyLC 57▶ START
MEDIUM2:08Minimum Number of Arrows to Burst Balloons
GreedyLC 452▶ START
MEDIUM2:00Partition Labels
GreedyLC 763▶ START
MEDIUM2:11Boats to Save People
GreedyLC 881▶ START
MEDIUM2:06Remove K Digits
GreedyLC 402▶ START
MEDIUM2:01Two City Scheduling
GreedyLC 1029▶ START
MEDIUM2:06Valid Parenthesis String
Greedy rangeLC 678▶ START
MEDIUM2:08Maximum Subarray
GreedyLC 53▶ START
MEDIUM2:10Hand of Straights
GreedyLC 846▶ START
MEDIUM2:07Task Scheduler
GreedyLC 621▶ START
MEDIUM2:02Merge Triplets to Form Target Triplet
GreedyLC 1899▶ START