Greedy Algorithms
A greedy algorithm makes the best-looking choice at each step and never goes back on it. The real work is convincing yourself that the local choice is safe, which is why greedy problems are quick to code and hard to trust.
The eight chapters cover general greedy strategies, interval scheduling, greedy on strings, greedy on numbers, constructive problems and brainteasers, construction problems, interactive problems, and a mixed set. It suits people who handle medium array problems and want to get better at seeing why a greedy choice holds.
Want company while you work through this list? Sign in, open the study room, and your heroine will bring you the problems one at a time.
I. Greedy Strategies
§1.1 Greedy from Extrema
§1.2 Single Sequence Pairing
§1.3 Two-Sequence Pairing
§1.4 Greedy from the Left or Right End
§1.5 Partition Greedy
§1.6 Enumerate First, Then Greedy
§1.7 Exchange Argument
§1.8 Keeping Neighbors Different
II. Interval Scheduling
§2.1 Disjoint Intervals
| Problem | Rating |
|---|---|
| 435. Non Overlapping Intervals | 1700 |
| 646. Maximum Length of Pair Chain | Unrated |
| 1520. Maximum Number of Non Overlapping Substrings | 2363 |
| 3458. Select K Disjoint Special Substrings | Unrated |
§2.3 Choosing Points to Stab Intervals
| Problem | Rating |
|---|---|
| 452. Minimum Number of Arrows to Burst Balloons | 1700 |
| 757. Set Intersection Size at Least Two | 2379 |
§2.4 Interval Covering
| Problem | Rating |
|---|---|
| 45. Jump Game II | 1700 |
| 1024. Video Stitching | 1746 |
| 1326. Minimum Number of Taps to Open to Water a Garden | 1885 |
§2.5 Merging Intervals
| Problem | Rating |
|---|---|
| 56. Merge Intervals | Unrated |
| 57. Insert Interval | Unrated |
| 55. Jump Game | Unrated |
| 763. Partition Labels | 1443 |
| 3169. Count Days Without Meetings | 1483 |
| 2580. Count Ways to Group Overlapping Ranges | 1632 |
| 3394. Check If Grid Can Be Cut Into Sections | 1916 |
§2.6 Other Interval Greedy
| Problem | Rating |
|---|---|
| 1288. Remove Covered Intervals | Unrated |
III. String Greedy
§3.1 Lexicographically Extrema
§3.2 Palindrome Greedy
IV. Mathematical Greedy
§4.1 Fundamentals
§4.2 Product Greedy
| Problem | Rating |
|---|---|
| 628. Maximum Product of Three Numbers | Unrated |
| 3732. Maximum Product of Three Elements After One Replacement | 1529 |
§4.3 Rearrangement Inequality
| Problem | Rating |
|---|---|
| 2285. Maximum Total Importance of Roads | 1496 |
| 3016. Minimum Number of Pushes to Type Word II | 1534 |
| 1402. Reducing Dishes | 1679 |
§4.4 AM-GM Inequality
| Problem | Rating |
|---|---|
| 1969. Minimum Non Zero Product of the Array Elements | 1967 |
| 3723. Maximize Sum of Squares of Digits | 1537 |
§4.5 Median Greedy
| Problem | Rating |
|---|---|
| 462. Minimum Moves to Equal Array Elements II | Unrated |
| 2033. Minimum Operations to Make a Uni Value Grid | 1672 |
| 2448. Minimum Cost to Make Array Equal | 2005 |
§4.6 Proof by Induction
| Problem | Rating |
|---|---|
| 2952. Minimum Number of Coins to Be Added | 1784 |
| 330. Patching Array | Unrated |
| 1798. Maximum Number of Consecutive Values You Can Make | 1931 |
§4.7 Other Math Greedy
| Problem | Rating |
|---|---|
| 3107. Minimum Operations to Make Median of Array Equal to K | 1605 |
| 754. Reach a Number | 2000 |
V. Constructive & Brainteasers
§5.1 Special to General Case
§5.2 Brainteasers
§5.3 Thinking in Reverse
§5.4 Equivalent Reformulation
VI. Construction Problems
§6.1 Construction Problems
VII. Interactive Problems
VII. Interactive Problems
| Problem | Rating |
|---|---|
| 1237. Find Positive Integer Solution for a Given Equation | Unrated |
| 843. Guess the Word | 2078 |
VIII. Miscellaneous Greedy
VIII. Miscellaneous Greedy
The route places this plan between Bit Manipulation and Mathematics, and you can tick off single chapters or sections here if you have already covered them.
Ratings come from zerotrac's LeetCode contest ratings. Some problems have no zerotrac rating and are marked Unrated.
Open the study room