← back

Greedy

406 questions · 0 seen

All Greedy problems

Problems

11 Container With Most Water
44 Wildcard Matching
45 Jump Game II
55 Jump Game
122 Best Time to Buy and Sell Stock II
134 Gas Station
135 Candy
179 Largest Number
316 Remove Duplicate Letters
321 Create Maximum Number
324 Wiggle Sort II
330 Patching Array
334 Increasing Triplet Subsequence
376 Wiggle Subsequence
397 Integer Replacement
402 Remove K Digits
409 Longest Palindrome
410 Split Array Largest Sum
420 Strong Password Checker
435 Non-overlapping Intervals
452 Minimum Number of Arrows to Burst Balloons
455 Assign Cookies
502 IPO
517 Super Washing Machines
561 Array Partition
581 Shortest Unsorted Continuous Subarray
605 Can Place Flowers
611 Valid Triangle Number
621 Task Scheduler
624 Maximum Distance in Arrays (PRO)
630 Course Schedule III
632 Smallest Range Covering Elements from K Lists
646 Maximum Length of Pair Chain
649 Dota2 Senate
659 Split Array into Consecutive Subsequences
670 Maximum Swap
678 Valid Parenthesis String
680 Valid Palindrome II
714 Best Time to Buy and Sell Stock with Transaction Fee
738 Monotone Increasing Digits
757 Set Intersection Size At Least Two
763 Partition Labels
765 Couples Holding Hands
767 Reorganize String
768 Max Chunks To Make Sorted II
769 Max Chunks To Make Sorted
781 Rabbits in Forest
807 Max Increase to Keep City Skyline
826 Most Profit Assigning Work
846 Hand of Straights
857 Minimum Cost to Hire K Workers
860 Lemonade Change
861 Score After Flipping Matrix
870 Advantage Shuffle
871 Minimum Number of Refueling Stops
881 Boats to Save People
910 Smallest Range II
921 Minimum Add to Make Parentheses Valid
936 Stamping The Sequence
942 DI String Match
945 Minimum Increment to Make Array Unique
948 Bag of Tokens
954 Array of Doubled Pairs
955 Delete Columns to Make Sorted II
969 Pancake Sorting
976 Largest Perimeter Triangle
984 String Without AAA or BBB
991 Broken Calculator
1005 Maximize Sum Of Array After K Negations
1007 Minimum Domino Rotations For Equal Row
1013 Partition Array Into Three Parts With Equal Sum
1024 Video Stitching
1029 Two City Scheduling
1053 Previous Permutation With One Swap
1054 Distant Barcodes
1081 Smallest Subsequence of Distinct Characters
1090 Largest Values From Labels
1130 Minimum Cost Tree From Leaf Values
1144 Decrease Elements To Make Array Zigzag
1147 Longest Chunked Palindrome Decomposition
1217 Minimum Cost to Move Chips to The Same Position
1221 Split a String in Balanced Strings
1247 Minimum Swaps to Make Strings Equal
1253 Reconstruct a 2-Row Binary Matrix
1262 Greatest Sum Divisible by Three
1282 Group the People Given the Group Size They Belong To
1296 Divide Array in Sets of K Consecutive Numbers
1323 Maximum 69 Number
1326 Minimum Number of Taps to Open to Water a Garden
1328 Break a Palindrome
1330 Reverse Subarray To Maximize Array Value
1338 Reduce Array Size to The Half
1353 Maximum Number of Events That Can Be Attended
1363 Largest Multiple of Three
1382 Balance a Binary Search Tree
1383 Maximum Performance of a Team
1386 Cinema Seat Allocation
1388 Pizza With 3n Slices
1400 Construct K Palindrome Strings
1402 Reducing Dishes
1403 Minimum Subsequence in Non-Increasing Order
1405 Longest Happy String
1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
1432 Max Difference You Can Get From Changing an Integer
1433 Check If a String Can Break Another String
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
1481 Least Number of Unique Integers after K Removals
1488 Avoid Flood in The City
1505 Minimum Possible Integer After at Most K Adjacent Swaps On Digits
1509 Minimum Difference Between Largest and Smallest Value in Three Moves
1520 Maximum Number of Non-Overlapping Substrings
1526 Minimum Number of Increments on Subarrays to Form a Target Array
1529 Minimum Suffix Flips
1536 Minimum Swaps to Arrange a Binary Grid
1537 Get the Maximum Score
1541 Minimum Insertions to Balance a Parentheses String
1546 Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
1558 Minimum Numbers of Function Calls to Make Target Array
1561 Maximum Number of Coins You Can Get
1567 Maximum Length of Subarray With Positive Product
1578 Minimum Time to Make Rope Colorful
1585 Check If String Is Transformable With Substring Sort Operations
1589 Maximum Sum Obtained of Any Permutation
1605 Find Valid Matrix Given Row and Column Sums
1642 Furthest Building You Can Reach
1647 Minimum Deletions to Make Character Frequencies Unique
1648 Sell Diminishing-Valued Colored Balls
1663 Smallest String With A Given Numeric Value
1665 Minimum Initial Energy to Finish Tasks
1671 Minimum Number of Removals to Make Mountain Array
1673 Find the Most Competitive Subsequence
1675 Minimize Deviation in Array (PRO)
1686 Stone Game VI
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers
1702 Maximum Binary String After Change
1703 Minimum Adjacent Swaps for K Consecutive Ones
1705 Maximum Number of Eaten Apples
1710 Maximum Units on a Truck
1713 Minimum Operations to Make a Subsequence
1717 Maximum Score From Removing Substrings
1727 Largest Submatrix With Rearrangements
1733 Minimum Number of People to Teach
1736 Latest Time by Replacing Hidden Digits
1739 Building Boxes
1753 Maximum Score From Removing Stones
1754 Largest Merge Of Two Strings
1764 Form Array by Concatenating Subarrays of Another Array
1775 Equal Sum Arrays With Minimum Number of Operations
1785 Minimum Elements to Add to Form a Given Sum
1792 Maximum Average Pass Ratio (PRO)
1798 Maximum Number of Consecutive Values You Can Make
1802 Maximum Value at a Given Index in a Bounded Array
1824 Minimum Sideway Jumps
1827 Minimum Operations to Make the Array Increasing
1833 Maximum Ice Cream Bars
1838 Frequency of the Most Frequent Element
1846 Maximum Element After Decreasing and Rearranging
1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number
1864 Minimum Number of Swaps to Make the Binary String Alternating
1877 Minimize Maximum Pair Sum in Array
1881 Maximum Value after Insertion
1899 Merge Triplets to Form Target Triplet
1903 Largest Odd Number in String (PRO)
1921 Eliminate Maximum Number of Monsters
1927 Sum Game
1936 Add Minimum Number of Rungs
1946 Largest Number After Mutating Substring
1953 Maximum Number of Weeks for Which You Can Work
1962 Remove Stones to Minimize the Total (PRO)
1963 Minimum Number of Swaps to Make the String Balanced (PRO)
1968 Array With Elements Not Equal to Average of Neighbors
1969 Minimum Non-Zero Product of the Array Elements
1974 Minimum Time to Type Word Using Special Typewriter (PRO)
1975 Maximum Matrix Sum
1996 The Number of Weak Characters in the Game
2007 Find Original Array From Doubled Array
2027 Minimum Moves to Convert String
2029 Stone Game IX
2030 Smallest K-Length Subsequence With Occurrences of a Letter
2037 Minimum Number of Moves to Seat Everyone
2038 Remove Colored Pieces if Both Neighbors are the Same Color
2064 Minimized Maximum of Products Distributed to Any Store
2071 Maximum Number of Tasks You Can Assign
2078 Two Furthest Houses With Different Colors
2086 Minimum Number of Food Buckets to Feed the Hamsters
2087 Minimum Cost Homecoming of a Robot in a Grid
2091 Removing Minimum and Maximum From Array
2116 Check if a Parentheses String Can Be Valid
2126 Destroying Asteroids
2131 Longest Palindrome by Concatenating Two Letter Words
2132 Stamping the Grid
2136 Earliest Possible Day of Full Bloom
2139 Minimum Moves to Reach Target Score
2141 Maximum Running Time of N Computers
2144 Minimum Cost of Buying Candies With Discount
2160 Minimum Sum of Four Digit Number After Splitting Digits
2170 Minimum Operations to Make the Array Alternating
2171 Removing Minimum Number of Magic Beans
2178 Maximum Split of Positive Even Integers
2182 Construct String With Repeat Limit
2193 Minimum Number of Moves to Make Palindrome
2195 Append K Integers With Minimal Sum
2202 Maximize the Topmost Element After K Moves
2207 Maximize Number of Subsequences in a String
2208 Minimum Operations to Halve Array Sum
2216 Minimum Deletions to Make Array Beautiful
2224 Minimum Number of Operations to Convert Time
2233 Maximum Product After K Increments
2234 Maximum Total Beauty of the Gardens
2241 Design an ATM Machine
2244 Minimum Rounds to Complete All Tasks
2259 Remove Digit From Number to Maximize Result
2271 Maximum White Tiles Covered by a Carpet
2279 Maximum Bags With Full Capacity of Rocks
2285 Maximum Total Importance of Roads
2294 Partition Array Such That Maximum Difference Is K
2310 Sum of Numbers With Units Digit K
2311 Longest Binary Subsequence Less Than or Equal to K
2333 Minimum Sum of Squared Difference
2335 Minimum Amount of Time to Fill Cups
2350 Shortest Impossible Sequence of Rolls
2357 Make Array Zero by Subtracting Equal Amounts
2358 Maximum Number of Groups Entering a Competition
2366 Minimum Replacements to Sort the Array
2375 Construct Smallest Number From DI String
2383 Minimum Hours of Training to Win a Competition
2384 Largest Palindromic Number
2389 Longest Subsequence With Limited Sum
2405 Optimal Partition of String
2406 Divide Intervals Into Minimum Number of Groups
2410 Maximum Matching of Players With Trainers
2412 Minimum Money Required Before Transactions
2429 Minimize XOR
2434 Using a Robot to Print the Lexicographically Smallest String
2439 Minimize Maximum of Array
2448 Minimum Cost to Make Array Equal
2449 Minimum Number of Operations to Make Arrays Similar
2457 Minimum Addition to Make Integer Beautiful
2472 Maximum Number of Non-overlapping Palindrome Substrings
2486 Append Characters to String to Make Subsequence
2497 Maximum Star Sum of a Graph
2498 Frog Jump II
2499 Minimum Total Cost to Make Arrays Unequal
2517 Maximum Tastiness of Candy Basket
2522 Partition String Into Substrings With Values at Most K
2528 Maximize the Minimum Powered City
2530 Maximal Score After Applying K Operations
2541 Minimum Operations to Make Array Equal II
2542 Maximum Subsequence Score
2551 Put Marbles in Bags
2554 Maximum Number of Integers to Choose From a Range I
2560 House Robber IV
2561 Rearranging Fruits
2566 Maximum Difference by Remapping a Digit
2567 Minimum Score by Changing Two Elements
2571 Minimum Operations to Reduce an Integer to 0
2573 Find the String with LCP
2576 Find the Maximum Number of Marked Indices
2578 Split With Minimum Sum
2587 Rearrange Array to Maximize Prefix Score
2589 Minimum Time to Complete All Tasks
2591 Distribute Money to Maximum Children
2592 Maximize Greatness of an Array
2598 Smallest Missing Non-negative Integer After Operations (PRO)
2600 K Items With the Maximum Sum
2601 Prime Subtraction Operation
2607 Make K-Subarray Sums Equal
2611 Mice and Cheese
2616 Minimize the Maximum Difference of Pairs
2645 Minimum Additions to Make Valid String
2656 Maximum Sum With Exactly K Elements
2659 Make Array Empty
2663 Lexicographically Smallest Beautiful String
2673 Make Costs of Paths Equal in a Binary Tree
2680 Maximum OR
2697 Lexicographically Smallest Palindrome
2706 Buy Two Chocolates
2708 Maximum Strength of a Group
2712 Minimum Cost to Make All Characters Equal
2734 Lexicographically Smallest String After Substring Operation
2745 Construct the Longest New String
2789 Largest Element in an Array after Merge Operations
2790 Maximum Number of Groups With Increasing Length
2800 Shortest String That Contains Three Strings
2811 Check if it is Possible to Split Array
2813 Maximum Elegance of a K-Length Subsequence
2818 Apply Operations to Maximize Score
2829 Determine the Minimum Sum of a k-avoiding Array
2834 Find the Minimum Possible Sum of a Beautiful Array
2835 Minimum Operations to Form Subsequence With Target Sum
2842 Count K-Subsequences of a String With Maximum Beauty
2844 Minimum Operations to Make a Special Number
2856 Minimum Array Length After Pair Removals
2864 Maximum Odd Binary Number
2870 Minimum Number of Operations to Make Array Empty
2871 Split Array Into Maximum Number of Subarrays
2895 Minimum Processing Time
2897 Apply Operations on Array to Maximize Sum of Squares
2900 Longest Unequal Adjacent Groups Subsequence I
2910 Minimum Number of Groups to Create a Valid Assignment
2918 Minimum Equal Sum of Two Arrays After Replacing Zeros
2931 Maximum Spending After Buying Items
2938 Separate Black and White Balls
2939 Maximum Xor Product
2952 Minimum Number of Coins to be Added
2957 Remove Adjacent Almost-Equal Characters
2966 Divide Array Into Arrays With Max Difference
2967 Minimum Cost to Make Array Equalindromic
2971 Find Polygon With the Largest Perimeter
3002 Maximum Size of a Set After Removals
3012 Minimize Length of Array Using Operations
3014 Minimum Number of Pushes to Type Word I
3016 Minimum Number of Pushes to Type Word II
3022 Minimize OR of Remaining Elements Using Operations
3035 Maximum Palindromes After Operations
3049 Earliest Second to Mark Indices II
3068 Find the Maximum Sum of Node Values
3074 Apple Redistribution into Boxes
3075 Maximize Happiness of Selected Children
3081 Replace Question Marks in String to Minimize Its Value
3085 Minimum Deletions to Make String K-Special
3086 Minimum Moves to Pick K Ones (PRO)
3091 Apply Operations to Make Sum of Array Greater Than or Equal to k
3106 Lexicographically Smallest String After Operations With Constraint
3107 Minimum Operations to Make Median of Array Equal to K
3111 Minimum Rectangles to Cover Points
3139 Minimum Cost to Equalize Array
3170 Lexicographically Minimum String After Removing Stars
3192 Minimum Operations to Make Binary Array Elements Equal to One II
3207 Maximum Points After Enemy Battles
3216 Lexicographically Smallest String After a Swap
3218 Minimum Cost for Cutting Cake I
3219 Minimum Cost for Cutting Cake II
3228 Maximum Number of Operations to Move Ones to the End (PRO)
3229 Minimum Operations to Make Array Equal to Target
3244 Shortest Distance After Road Addition Queries II
3260 Find the Largest Palindrome Divisible by K
3273 Minimum Amount of Damage Dealt to Bob
3281 Maximize Score of Numbers in Ranges
3282 Reach End of Array With Max Score
3296 Minimum Number of Seconds to Make Mountain Height Zero
3301 Maximize the Total Height of Unique Towers
3302 Find the Lexicographically Smallest Valid Sequence
3326 Minimum Division Operations to Make Array Non Decreasing
3348 Smallest Divisible Digit Product II
3357 Minimize the Maximum Adjacent Element Difference
3362 Zero Array Transformation III
3397 Maximum Number of Distinct Elements After Operations
3402 Minimum Operations to Make Columns Strictly Increasing
3413 Maximum Coins From K Consecutive Bags
3424 Minimum Cost to Make Arrays Identical
3434 Maximum Frequency After Subarray Operation
3439 Reschedule Meetings for Maximum Free Time I
3440 Reschedule Meetings for Maximum Free Time II
3449 Maximize the Minimum Game Score (PRO)
3457 Eat Pizzas!
3458 Select K Disjoint Special Substrings
3462 Maximum Sum With at Most K Elements
3474 Lexicographically Smallest Generated String
3487 Maximum Unique Subarray Sum After Deletion
3523 Make Array Non-decreasing
3534 Path Existence Queries in a Graph II
3542 Minimum Operations to Convert All Elements to Zero
3545 Minimum Deletions for At Most K Distinct Characters
3547 Maximum Sum of Edge Values in a Graph
3557 Find Maximum Number of Non Intersecting Substrings
3572 Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values
3576 Transform Array to All Equal Elements
3579 Minimum Steps to Convert String with Operations
3587 Minimum Adjacent Swaps to Alternate Parity
3588 Find Maximum Area of a Triangle
3600 Maximize Spanning Tree Stability with Upgrades
3605 Minimum Stability Factor of Array
3627 Maximum Median Sum of Subsequences of Size 3
3628 Maximum Number of Subsequences After One Inserting
3630 Partition Array for Maximum XOR and AND
3633 Earliest Finish Time for Land and Water Rides I
3635 Earliest Finish Time for Land and Water Rides II
3638 Maximum Balanced Shipments
3645 Maximum Total from Optimal Activation Order
3675 Minimum Operations to Transform String
3680 Generate Schedule
3681 Maximum XOR of Subsequences
3684 Maximize Sum of At Most K Distinct Elements
3689 Maximum Total Subarray Value I
3691 Maximum Total Subarray Value II
3695 Maximize Alternating Sum Using Swaps
3720 Lexicographically Smallest Permutation Greater Than Target
3723 Maximize Sum of Squares of Digits
3724 Minimum Operations to Transform Array
3727 Maximum Alternating Sum of Squares
3732 Maximum Product of Three Elements After One Replacement
3745 Maximize Expression of Three Elements
3752 Lexicographically Smallest Negated Permutation that Sums to Target
3767 Maximize Points After Choosing K Tasks
3776 Minimum Moves to Balance Circular Array
3780 Maximum Sum of Three Numbers Divisible by Three
3781 Maximum Score After Binary Swaps
3785 Minimum Swaps to Avoid Forbidden Values
3789 Minimum Cost to Acquire Required Items
3796 Find Maximum Value in a Constrained Sequence
3800 Minimum Cost to Make Two Binary Strings Equal
3806 Maximum Bitwise AND After Increment Operations
3810 Minimum Operations to Reach Target Array
3816 Lexicographically Smallest String After Deleting Duplicate Characters
3849 Maximum Bitwise XOR After Rearrangement