Greedy | LeetCode Problems

286 Greedy solutions to LeetCode solutions.

Greedy Problems View all solutions →

Container With Most Water

#11 Medium

Wildcard Matching

#44 Hard

Jump Game II

#45 Medium

Jump Game

#55 Medium

Best Time to Buy and Sell Stock II

#122 Medium

Gas Station

#134 Medium

Candy

#135 Hard

Largest Number

#179 Medium

Remove Duplicate Letters

#316 Medium

Create Maximum Number

#321 Hard

Wiggle Sort II

#324 Medium

Patching Array

#330 Hard

Increasing Triplet Subsequence

#334 Medium

Wiggle Subsequence

#376 Medium

Integer Replacement

#397 Medium

Remove K Digits

#402 Medium

Longest Palindrome

#409 Easy

Split Array Largest Sum

#410 Hard

Strong Password Checker

#420 Hard

Non-overlapping Intervals

#435 Medium

Minimum Number of Arrows to Burst Balloons

#452 Medium

Assign Cookies

#455 Easy

IPO

#502 Hard

Super Washing Machines

#517 Hard

Array Partition

#561 Easy

Shortest Unsorted Continuous Subarray

#581 Medium

Can Place Flowers

#605 Easy

Valid Triangle Number

#611 Medium

Task Scheduler

#621 Medium

Maximum Distance in Arrays

#624 Medium

Course Schedule III

#630 Hard

Smallest Range Covering Elements from K Lists

#632 Hard

Maximum Length of Pair Chain

#646 Medium

Dota2 Senate

#649 Medium

Split Array into Consecutive Subsequences

#659 Medium

Maximum Swap

#670 Medium

Valid Parenthesis String

#678 Medium

Valid Palindrome II

#680 Easy

Best Time to Buy and Sell Stock with Transaction Fee

#714 Medium

Monotone Increasing Digits

#738 Medium

Set Intersection Size At Least Two

#757 Hard

Partition Labels

#763 Medium

Couples Holding Hands

#765 Hard

Reorganize String

#767 Medium

Max Chunks To Make Sorted II

#768 Hard

Max Chunks To Make Sorted

#769 Medium

Rabbits in Forest

#781 Medium

Max Increase to Keep City Skyline

#807 Medium

Most Profit Assigning Work

#826 Medium

Hand of Straights

#846 Medium

Minimum Cost to Hire K Workers

#857 Hard

Lemonade Change

#860 Easy

Score After Flipping Matrix

#861 Medium

Advantage Shuffle

#870 Medium

Minimum Number of Refueling Stops

#871 Hard

Boats to Save People

#881 Medium

Smallest Range II

#910 Medium

Minimum Add to Make Parentheses Valid

#921 Medium

Stamping The Sequence

#936 Hard

DI String Match

#942 Easy

Minimum Increment to Make Array Unique

#945 Medium

Bag of Tokens

#948 Medium

Array of Doubled Pairs

#954 Medium

Delete Columns to Make Sorted II

#955 Medium

Pancake Sorting

#969 Medium

Largest Perimeter Triangle

#976 Easy

String Without AAA or BBB

#984 Medium

Broken Calculator

#991 Medium

Maximize Sum Of Array After K Negations

#1005 Easy

Minimum Domino Rotations For Equal Row

#1007 Medium

Partition Array Into Three Parts With Equal Sum

#1013 Easy

Video Stitching

#1024 Medium

Two City Scheduling

#1029 Medium

Previous Permutation With One Swap

#1053 Medium

Distant Barcodes

#1054 Medium

Smallest Subsequence of Distinct Characters

#1081 Medium

Largest Values From Labels

#1090 Medium

Minimum Cost Tree From Leaf Values

#1130 Medium

Decrease Elements To Make Array Zigzag

#1144 Medium

Longest Chunked Palindrome Decomposition

#1147 Hard

Minimum Cost to Move Chips to The Same Position

#1217 Easy

Split a String in Balanced Strings

#1221 Easy

Minimum Swaps to Make Strings Equal

#1247 Medium

Reconstruct a 2-Row Binary Matrix

#1253 Medium

Greatest Sum Divisible by Three

#1262 Medium

Group the People Given the Group Size They Belong To

#1282 Medium

Divide Array in Sets of K Consecutive Numbers

#1296 Medium

Maximum 69 Number

#1323 Easy

Minimum Number of Taps to Open to Water a Garden

#1326 Hard

Break a Palindrome

#1328 Medium

Reverse Subarray To Maximize Array Value

#1330 Hard

Reduce Array Size to The Half

#1338 Medium

Maximum Number of Events That Can Be Attended

#1353 Medium

Largest Multiple of Three

#1363 Hard

Balance a Binary Search Tree

#1382 Medium

Maximum Performance of a Team

#1383 Hard

Cinema Seat Allocation

#1386 Medium

Pizza With 3n Slices

#1388 Hard

Construct K Palindrome Strings

#1400 Medium

Reducing Dishes

#1402 Hard

Minimum Subsequence in Non-Increasing Order

#1403 Easy

Longest Happy String

#1405 Medium

Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

#1414 Medium

Max Difference You Can Get From Changing an Integer

#1432 Medium

Check If a String Can Break Another String

#1433 Medium

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

#1465 Medium

Least Number of Unique Integers after K Removals

#1481 Medium

Avoid Flood in The City

#1488 Medium

Minimum Possible Integer After at Most K Adjacent Swaps On Digits

#1505 Hard

Minimum Difference Between Largest and Smallest Value in Three Moves

#1509 Medium

Maximum Number of Non-Overlapping Substrings

#1520 Hard

Minimum Number of Increments on Subarrays to Form a Target Array

#1526 Hard

Minimum Suffix Flips

#1529 Medium

Minimum Swaps to Arrange a Binary Grid

#1536 Medium

Get the Maximum Score

#1537 Hard

Minimum Insertions to Balance a Parentheses String

#1541 Medium

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

#1546 Medium

Minimum Numbers of Function Calls to Make Target Array

#1558 Medium

Maximum Number of Coins You Can Get

#1561 Medium

Maximum Length of Subarray With Positive Product

#1567 Medium

Minimum Time to Make Rope Colorful

#1578 Medium

Check If String Is Transformable With Substring Sort Operations

#1585 Hard

Maximum Sum Obtained of Any Permutation

#1589 Medium

Find Valid Matrix Given Row and Column Sums

#1605 Medium

Find Servers That Handled Most Number of Requests

#1606 Hard

Furthest Building You Can Reach

#1642 Medium

Minimum Deletions to Make Character Frequencies Unique

#1647 Medium

Sell Diminishing-Valued Colored Balls

#1648 Medium

Smallest String With A Given Numeric Value

#1663 Medium

Minimum Initial Energy to Finish Tasks

#1665 Hard

Minimum Number of Removals to Make Mountain Array

#1671 Hard

Find the Most Competitive Subsequence

#1673 Medium

Minimize Deviation in Array

#1675 Hard

Stone Game VI

#1686 Medium

Partitioning Into Minimum Number Of Deci-Binary Numbers

#1689 Medium

Maximum Binary String After Change

#1702 Medium

Minimum Adjacent Swaps for K Consecutive Ones

#1703 Hard

Maximum Number of Eaten Apples

#1705 Medium

Maximum Units on a Truck

#1710 Easy

Minimum Operations to Make a Subsequence

#1713 Hard

Maximum Score From Removing Substrings

#1717 Medium

Largest Submatrix With Rearrangements

#1727 Medium

Minimum Number of People to Teach

#1733 Medium

Latest Time by Replacing Hidden Digits

#1736 Easy

Building Boxes

#1739 Hard

Maximum Score From Removing Stones

#1753 Medium

Largest Merge Of Two Strings

#1754 Medium

Form Array by Concatenating Subarrays of Another Array

#1764 Medium

Equal Sum Arrays With Minimum Number of Operations

#1775 Medium

Minimum Elements to Add to Form a Given Sum

#1785 Medium

Maximum Average Pass Ratio

#1792 Medium

Maximum Number of Consecutive Values You Can Make

#1798 Medium

Maximum Value at a Given Index in a Bounded Array

#1802 Medium

Minimum Sideway Jumps

#1824 Medium

Minimum Operations to Make the Array Increasing

#1827 Easy

Maximum Ice Cream Bars

#1833 Medium

Frequency of the Most Frequent Element

#1838 Medium

Maximum Element After Decreasing and Rearranging

#1846 Medium

Minimum Adjacent Swaps to Reach the Kth Smallest Number

#1850 Medium

Minimum Number of Swaps to Make the Binary String Alternating

#1864 Medium

Minimize Maximum Pair Sum in Array

#1877 Medium

Maximum Value after Insertion

#1881 Medium

Minimum Number of Flips to Make the Binary String Alternating

#1888 Medium

Merge Triplets to Form Target Triplet

#1899 Medium

Largest Odd Number in String

#1903 Easy

Eliminate Maximum Number of Monsters

#1921 Medium

Sum Game

#1927 Medium

Add Minimum Number of Rungs

#1936 Medium

Largest Number After Mutating Substring

#1946 Medium

Maximum Number of Weeks for Which You Can Work

#1953 Medium

Minimum Number of Swaps to Make the String Balanced

#1963 Medium

Array With Elements Not Equal to Average of Neighbors

#1968 Medium

Minimum Non-Zero Product of the Array Elements

#1969 Medium

Minimum Time to Type Word Using Special Typewriter

#1974 Easy

Maximum Matrix Sum

#1975 Medium

The Number of Weak Characters in the Game

#1996 Medium

Find Original Array From Doubled Array

#2007 Medium

Longest Subsequence Repeated k Times

#2014 Hard

Minimum Moves to Convert String

#2027 Easy

Stone Game IX

#2029 Medium

Smallest K-Length Subsequence With Occurrences of a Letter

#2030 Hard

Minimum Number of Moves to Seat Everyone

#2037 Easy

Remove Colored Pieces if Both Neighbors are the Same Color

#2038 Medium

Minimized Maximum of Products Distributed to Any Store

#2064 Medium

Maximum Number of Tasks You Can Assign

#2071 Hard

Two Furthest Houses With Different Colors

#2078 Easy

Minimum Number of Food Buckets to Feed the Hamsters

#2086 Medium

Minimum Cost Homecoming of a Robot in a Grid

#2087 Medium

Removing Minimum and Maximum From Array

#2091 Medium

Check if a Parentheses String Can Be Valid

#2116 Medium

Destroying Asteroids

#2126 Medium

Longest Palindrome by Concatenating Two Letter Words

#2131 Medium

Stamping the Grid

#2132 Hard

Earliest Possible Day of Full Bloom

#2136 Hard

Minimum Moves to Reach Target Score

#2139 Medium

Maximum Running Time of N Computers

#2141 Hard

Minimum Cost of Buying Candies With Discount

#2144 Easy

Minimum Sum of Four Digit Number After Splitting Digits

#2160 Easy

Minimum Operations to Make the Array Alternating

#2170 Medium

Removing Minimum Number of Magic Beans

#2171 Medium

Maximum Split of Positive Even Integers

#2178 Medium

Minimum Number of Moves to Make Palindrome

#2193 Hard

Append K Integers With Minimal Sum

#2195 Medium

Maximize the Topmost Element After K Moves

#2202 Medium

Maximize Number of Subsequences in a String

#2207 Medium

Minimum Deletions to Make Array Beautiful

#2216 Medium

Minimum Number of Operations to Convert Time

#2224 Easy

Maximum Total Beauty of the Gardens

#2234 Hard

Design an ATM Machine

#2241 Medium

Minimum Rounds to Complete All Tasks

#2244 Medium

Remove Digit From Number to Maximize Result

#2259 Easy

Maximum White Tiles Covered by a Carpet

#2271 Medium

Maximum Bags With Full Capacity of Rocks

#2279 Medium

Partition Array Such That Maximum Difference Is K

#2294 Medium

Shortest Impossible Sequence of Rolls

#2350 Hard

Maximum Number of Groups Entering a Competition

#2358 Medium

Minimum Replacements to Sort the Array

#2366 Hard

Construct Smallest Number From DI String

#2375 Medium

Minimum Hours of Training to Win a Competition

#2383 Easy

Longest Subsequence With Limited Sum

#2389 Easy

Optimal Partition of String

#2405 Medium

Maximum Matching of Players With Trainers

#2410 Medium

Minimum Money Required Before Transactions

#2412 Hard

Minimize XOR

#2429 Medium

Using a Robot to Print the Lexicographically Smallest String

#2434 Medium

Minimize Maximum of Array

#2439 Medium

Minimum Cost to Make Array Equal

#2448 Hard

Minimum Number of Operations to Make Arrays Similar

#2449 Hard

Maximum Number of Non-overlapping Palindrome Substrings

#2472 Hard

Append Characters to String to Make Subsequence

#2486 Medium

Frog Jump II

#2498 Medium

Minimum Total Cost to Make Arrays Unequal

#2499 Hard

Maximum Tastiness of Candy Basket

#2517 Medium

Partition String Into Substrings With Values at Most K

#2522 Medium

Maximum Subsequence Score

#2542 Medium

Put Marbles in Bags

#2551 Hard

Maximum Number of Integers to Choose From a Range I

#2554 Medium

Maximum Difference by Remapping a Digit

#2566 Easy

Minimum Score by Changing Two Elements

#2567 Medium

Minimum Operations to Reduce an Integer to 0

#2571 Medium

Find the Maximum Number of Marked Indices

#2576 Medium

Split With Minimum Sum

#2578 Easy

Rearrange Array to Maximize Prefix Score

#2587 Medium

Maximize Greatness of an Array

#2592 Medium

Smallest Missing Non-negative Integer After Operations

#2598 Medium

K Items With the Maximum Sum

#2600 Easy

Prime Subtraction Operation

#2601 Medium

Minimize the Maximum Difference of Pairs

#2616 Medium

Minimum Additions to Make Valid String

#2645 Medium

Maximum Sum With Exactly K Elements

#2656 Easy

Make Costs of Paths Equal in a Binary Tree

#2673 Medium

Maximum OR

#2680 Medium

Lexicographically Smallest Palindrome

#2697 Easy

Buy Two Chocolates

#2706 Easy

Minimum Cost to Make All Characters Equal

#2712 Medium

Construct the Longest New String

#2745 Medium

Largest Element in an Array after Merge Operations

#2789 Medium

Apply Operations to Maximize Score

#2818 Hard

Determine the Minimum Sum of a k-avoiding Array

#2829 Medium

Maximum Odd Binary Number

#2864 Easy

Minimum Number of Operations to Make Array Empty

#2870 Medium

Split Array Into Maximum Number of Subarrays

#2871 Medium

Minimum Processing Time

#2895 Medium

Apply Operations on Array to Maximize Sum of Squares

#2897 Hard

Longest Unequal Adjacent Groups Subsequence I

#2900 Easy

Minimum Equal Sum of Two Arrays After Replacing Zeros

#2918 Medium

Separate Black and White Balls

#2938 Medium

Minimum Number of Coins to be Added

#2952 Medium

Remove Adjacent Almost-Equal Characters

#2957 Medium

Divide Array Into Arrays With Max Difference

#2966 Medium

Find Polygon With the Largest Perimeter

#2971 Medium

Maximum Size of a Set After Removals

#3002 Medium

Minimum Number of Pushes to Type Word I

#3014 Easy

Minimum Number of Pushes to Type Word II

#3016 Medium

Maximum Palindromes After Operations

#3035 Medium

Find the Maximum Sum of Node Values

#3068 Hard

Apple Redistribution into Boxes

#3074 Easy

Maximize Happiness of Selected Children

#3075 Medium

Minimum Deletions to Make String K-Special

#3085 Medium

Apply Operations to Make Sum of Array Greater Than or Equal to k

#3091 Medium

Lexicographically Minimum String After Removing Stars

#3170 Medium

Zero Array Transformation III

#3362 Medium

Maximum Number of Distinct Elements After Operations

#3397 Medium

Minimum Operations to Make Columns Strictly Increasing

#3402 Easy

Maximum Sum With at Most K Elements

#3462 Medium

Maximize the Distance Between Points on a Square

#3464 Hard