DOKICODE
Study room

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.

254 problemsRating 1148–30778 Chapters
Open the study room

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

ProblemRating
3074. Apple Redistribution Into Boxes1198
3545. Minimum Deletions for at Most K Distinct Characters1211
2279. Maximum Bags with Full Capacity of Rocks1249
1833. Maximum Ice Cream Bars1253
1005. Maximize Sum of Array After K Negations1275
1481. Least Number of Unique Integers After K Removals1284
1403. Minimum Subsequence in Non Increasing Order1288
3010. Divide an Array Into Subarrays with Minimum Cost I1292
1338. Reduce Array Size to the Half1303
1710. Maximum Units on a Truck1310
3075. Maximize Happiness of Selected Children1326
2554. Maximum Number of Integers to Choose From a Range I1333
2126. Destroying Asteroids1335
2587. Rearrange Array to Maximize Prefix Score1337
976. Largest Perimeter Triangle1341
1561. Maximum Number of Coins You Can Get1406
3627. Maximum Median Sum of Subsequences of Size 31561
3462. Maximum Sum with at Most K Elements1416
2099. Find Subsequence of Length K with the Largest Sum1447
3301. Maximize the Total Height of Unique Towers1448
945. Minimum Increment to Make Array Unique1448
1846. Maximum Element After Decreasing AND Rearranging1454
3727. Maximum Alternating Sum of Squares1455
1647. Minimum Deletions to Make Character Frequencies Unique1510
2971. Find Polygon with the Largest Perimeter1521
2178. Maximum Split of Positive Even Integers1538
1578. Minimum Time to Make Rope Colorful1574
2567. Minimum Score by Changing Two Elements1609
1509. Minimum Difference Between Largest AND Smallest Value in Three Moves1653
3397. Maximum Number of Distinct Elements After Operations1687
3457. Eat Pizzas1704
948. Bag of Tokens1762
1775. Equal Sum Arrays with Minimum Number of Operations1850
3440. Reschedule Meetings for Maximum Free Time II1998
2333. Minimum Sum of Squared Difference2011
3645. Maximum Total From Optimal Activation Order2019

II. Interval Scheduling

§2.3 Choosing Points to Stab Intervals

ProblemRating
452. Minimum Number of Arrows to Burst Balloons1700
757. Set Intersection Size at Least Two2379

§2.6 Other Interval Greedy

ProblemRating
1288. Remove Covered IntervalsUnrated

III. String Greedy

IV. Mathematical Greedy

V. Constructive & Brainteasers

VI. Construction Problems

VII. Interactive Problems

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