DOKICODE
書斎

貪欲法

貪欲法は、各ステップでその場で一番よさそうな選択をし、後から取り消しません。大変なのは、その局所的な選択が本当に正しいと納得することです。だから貪欲法の問題は、コードは短いのに自信を持ちにくいのです。

8 つの章は、一般的な貪欲戦略、区間スケジューリング、文字列の貪欲法、数学の貪欲法、構築と発想問題、構築問題、インタラクティブ問題、その他の貪欲法の順です。中程度の配列問題は解けるようになって、なぜその貪欲な選択で正しいのかを見抜く力をつけたい人に向いています。

254 問レーティング 1148–30778 章
書斎を開く

誰かと一緒にこの問題集を進めたいなら、ログインして書斎を開いてみてください。ヒロインが一問ずつ出題してくれます。

一、Greedy Strategy

§1.1 最小 / 最大からGreedyに決める

問題レーティング
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

二、区間のGreedy

§2.3 区間に点を選ぶ

問題レーティング
452. Minimum Number of Arrows to Burst Balloons1700
757. Set Intersection Size at Least Two2379

§2.6 その他の区間Greedy

問題レーティング
1288. Remove Covered Intervals未評価

三、文字列のGreedy

四、数学的なGreedy

§4.4 相加相乗平均の不等式

問題レーティング
1969. Minimum Non Zero Product of the Array Elements1967
3723. Maximize Sum of Squares of Digits1537

§4.7 その他の数学的なGreedy

問題レーティング
3107. Minimum Operations to Make Median of Array Equal to K1605
754. Reach a Number2000

五、思考問題

六、構築問題

七、インタラクティブ問題

七、インタラクティブ問題

問題レーティング
1237. Find Positive Integer Solution for a Given Equation未評価
843. Guess the Word2078

八、その他

ルートでは「ビット演算」と「数学」の間に置かれています。すでに練習した章やセクションは、個別にチェックして飛ばせます。

レーティングは zerotrac さんによる LeetCode コンテストレーティングです。zerotrac のレーティングがない問題は「未評価」と表示されます。

書斎を開く