Greedy - rFronteddu/general_wiki GitHub Wiki
Exercises
Easy (Greedy Basics)
- Assign Cookies Greedy idea: give the smallest cookie that satisfies the child.
- Best Time to Buy and Sell Stock II Greedy: take every profitable increase.
- Can Place Flowers Greedy placement with local checks.
- Maximum Subarray Kadane’s algorithm (greedy + DP).
- Lemonade Change Greedy: always give largest bills first.
Medium (Classic Greedy Interview Problems)
- Jump Game Greedy: maintain farthest reachable index.
- Jump Game II Greedy BFS-style range expansion.
- Gas Station Greedy reset when total becomes negative.
- Partition Labels Greedy intervals based on last occurrences.
- Non-overlapping Intervals Classic interval scheduling greedy.
Hard (Advanced Greedy)
- Candy Two-pass greedy.
- Minimum Number of Arrows to Burst Balloons Greedy interval merging.
- Remove K Digits Greedy with monotonic stack.
- Task Scheduler Greedy counting strategy.
- Course Schedule III Greedy + heap.
The 5 Core Greedy Patterns These Problems Teach
Interval Scheduling
Examples:
- Non-overlapping Intervals
- Minimum Number of Arrows to Burst Balloons
Farthest Reach
Examples:
- Jump Game
- Jump Game II
Greedy Local Choice
Examples:
- Assign Cookies
- Lemonade Change
Greedy + Stack
Example:
- Remove K Digits
Greedy + Heap
Example:
- Course Schedule III