Greedy Interview Questions

Locally optimal choices that yield global solutions.

378 problems

#Title
11Container With Most Water
42Trapping Rain Water
45Jump Game II
55Jump Game
122Best Time to Buy and Sell Stock II
134Gas Station
135Candy
316Remove Duplicate Letters
321Create Maximum Number
330Patching Array
376Wiggle Subsequence
392Is Subsequence
397Integer Replacement
402Remove K Digits
435Non-overlapping Intervals
452Minimum Number of Arrows to Burst Balloons
455Assign Cookies
484Find Permutation
621Task Scheduler
630Course Schedule III
646Maximum Length of Pair Chain
649Dota2 Senate
659Split Array into Consecutive Subsequences
738Monotone Increasing Digits
757Set Intersection Size At Least Two
759Employee Free Time
763Partition Labels
767Reorganize String
798Smallest Rotation with Highest Score
843Guess the Word
861Score After Flipping Matrix
870Advantage Shuffle
881Boats to Save People
936Stamping The Sequence
948Bag of Tokens
962Maximum Width Ramp
968Binary Tree Cameras
984String Without AAA or BBB
991Broken Calculator
995Minimum Number of K Consecutive Bit Flips
1005Maximize Sum Of Array After K Negations
1024Video Stitching
1029Two City Scheduling
1053Previous Permutation With One Swap
1055Shortest Way to Form String
1058Minimize Rounding Error to Meet Target
1081Smallest Subsequence of Distinct Characters
1090Largest Values From Labels
1111Maximum Nesting Depth of Two Valid Parentheses Strings
1163Last Substring in Lexicographical Order
1167Minimum Cost to Connect Sticks
1183Maximum Number of Ones
1196How Many Apples Can You Put into the Basket
1199Minimum Time to Build Blocks
1221Split a String in Balanced Strings
1247Minimum Swaps to Make Strings Equal
1249Minimum Remove to Make Valid Parentheses
1253Reconstruct a 2-Row Binary Matrix
1272Remove Interval
1282Group the People Given the Group Size They Belong To
1288Remove Covered Intervals
1296Divide Array in Sets of K Consecutive Numbers
1326Minimum Number of Taps to Open to Water a Garden
1338Reduce Array Size to The Half
1353Maximum Number of Events That Can Be Attended
1354Construct Target Array With Multiple Sums
1383Maximum Performance of a Team
1386Cinema Seat Allocation
1400Construct K Palindrome Strings
1402Reducing Dishes
1403Minimum Subsequence in Non-Increasing Order
1405Longest Happy String
1414Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
1419Minimum Number of Frogs Croaking
1432Max Difference You Can Get From Changing an Integer
1433Check If a String Can Break Another String
1488Avoid Flood in The City
1518Water Bottles
1520Maximum Number of Non-Overlapping Substrings
1526Minimum Number of Increments on Subarrays to Form a Target Array
1536Minimum Swaps to Arrange a Binary Grid
1546Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
1564Put Boxes Into the Warehouse I
1567Maximum Length of Subarray With Positive Product
1578Minimum Deletion Cost to Avoid Repeating Letters
1580Put Boxes Into the Warehouse II
1585Check If String Is Transformable With Substring Sort Operations
1589Maximum Sum Obtained of Any Permutation
1591Strange Printer II
1599Maximum Profit of Operating a Centennial Wheel
1605Find Valid Matrix Given Row and Column Sums
1616Split Two Strings to Make Palindrome
1632Rank Transform of a Matrix
1647Minimum Deletions to Make Character Frequencies Unique
1653Minimum Deletions to Make String Balanced
1663Smallest String With A Given Numeric Value
1665Minimum Initial Energy to Finish Tasks
1673Find the Most Competitive Subsequence
1674Minimum Moves to Make Array Complementary
1686Stone Game VI
1689Partitioning Into Minimum Number Of Deci-Binary Numbers
1702Maximum Binary String After Change
1705Maximum Number of Eaten Apples
1708Largest Subarray Length K
1710Maximum Units on a Truck
1717Maximum Score From Removing Substrings
1725Number Of Rectangles That Can Form The Largest Square
1727Largest Submatrix With Rearrangements
1733Minimum Number of People to Teach
1736Latest Time by Replacing Hidden Digits
1737Change Minimum Characters to Satisfy One of Three Conditions
1749Maximum Absolute Sum of Any Subarray
1754Largest Merge Of Two Strings
1758Minimum Changes To Make Alternating Binary String
1759Count Number of Homogenous Substrings
1762Buildings With an Ocean View
1764Form Array by Concatenating Subarrays of Another Array
1769Minimum Number of Operations to Move All Balls to Each Box
1775Equal Sum Arrays With Minimum Number of Operations
1785Minimum Elements to Add to Form a Given Sum
1788Maximize the Beauty of the Garden
1793Maximum Score of a Good Subarray
1794Count Pairs of Equal Substrings With Minimum Difference
1798Maximum Number of Consecutive Values You Can Make
1801Number of Orders in the Backlog
1815Maximum Number of Groups Getting Fresh Donuts
1824Minimum Sideway Jumps
1827Minimum Operations to Make the Array Increasing
1833Maximum Ice Cream Bars
1840Maximum Building Height
1842Next Palindrome Using Same Digits
1846Maximum Element After Decreasing and Rearranging
1850Minimum Adjacent Swaps to Reach the Kth Smallest Number
1864Minimum Number of Swaps to Make the Binary String Alternating
1874Minimize Product Sum of Two Arrays
1877Minimize Maximum Pair Sum in Array
1881Maximum Value after Insertion
1887Reduction Operations to Make the Array Elements Equal
1893Check if All the Integers in a Range Are Covered
1894Find the Student that Will Replace the Chalk
1897Redistribute Characters to Make All Strings Equal
1899Merge Triplets to Form Target Triplet
1911Maximum Alternating Subsequence Sum
1913Maximum Product Difference Between Two Pairs
1921Eliminate Maximum Number of Monsters
1927Sum Game
1936Add Minimum Number of Rungs
1946Largest Number After Mutating Substring
1953Maximum Number of Weeks for Which You Can Work
1975Maximum Matrix Sum
2027Minimum Moves to Convert String
2030Smallest K-Length Subsequence With Occurrences of a Letter
2036Maximum Alternating Subarray Sum
2037Minimum Number of Moves to Seat Everyone
2071Maximum Number of Tasks You Can Assign
2086Minimum Number of Buckets Required to Collect Rainwater from Houses
2087Minimum Cost Homecoming of a Robot in a Grid
2126Destroying Asteroids
2136Earliest Possible Day of Full Bloom
2139Minimum Moves to Reach Target Score
2141Maximum Running Time of N Computers
2144Minimum Cost of Buying Candies With Discount
2147Number of Ways to Divide a Long Corridor
2160Minimum Sum of Four Digit Number After Splitting Digits
2165Smallest Value of the Rearranged Number
2178Maximum Split of Positive Even Integers
2182Construct String With Repeat Limit
2193Minimum Number of Moves to Make Palindrome
2195Append K Integers With Minimal Sum
2207Maximize Number of Subsequences in a String
2214Minimum Health to Beat Game
2216Minimum Deletions to Make Array Beautiful
2224Minimum Number of Operations to Convert Time
2259Remove Digit From Number to Maximize Result
2263Make Array Non-decreasing or Non-increasing
2268Minimum Number of Keypresses
2279Maximum Bags With Full Capacity of Rocks
2285Maximum Total Importance of Roads
2294Partition Array Such That Maximum Difference Is K
2311Longest Binary Subsequence Less Than or Equal to K
2321Maximum Score Of Spliced Array
2323Find Minimum Time to Finish All Jobs II
2340Minimum Adjacent Swaps to Make a Valid Array
2366Minimum Replacements to Sort the Array
2371Minimize Maximum Value in a Grid
2375Construct Smallest Number From DI String
2383Minimum Hours of Training to Win a Competition
2384Largest Palindromic Number
2405Optimal Partition of String
2410Maximum Matching of Players With Trainers
2412Minimum Money Required Before Transactions
2417Closest Fair Integer
2422Merge Operations to Turn Array Into a Palindrome
2434Using a Robot to Print the Lexicographically Smallest String
2436Minimum Split Into Subarrays With GCD Greater Than One
2439Minimize Maximum of Array
2440Create Components With Same Value
2449Minimum Number of Operations to Make Arrays Similar
2457Minimum Addition to Make Integer Beautiful
2459Sort Array by Moving Items to Empty Space
2472Maximum Number of Non-overlapping Palindrome Substrings
2479Maximum XOR of Two Non-Overlapping Subtrees
2483Minimum Penalty for a Shop
2486Append Characters to String to Make Subsequence
2498Frog Jump II
2499Minimum Total Cost to Make Arrays Unequal
2522Partition String Into Substrings With Values at Most K
2541Minimum Operations to Make Array Equal II
2542Maximum Subsequence Score
2548Maximum Price to Fill a Bag
2551Put Marbles in Bags
2561Rearranging Fruits
2566Maximum Difference by Remapping a Digit
2567Minimum Score by Changing Two Elements
2571Minimum Operations to Reduce an Integer to 0
2573Find the String with LCP
2576Find the Maximum Number of Marked Indices
2578Split With Minimum Sum
2587Rearrange Array to Maximize Prefix Score
2589Minimum Time to Complete All Tasks
2591Distribute Money to Maximum Children
2599Make the Prefix Sum Non-negative
2600K Items With the Maximum Sum
2601Prime Subtraction Operation
2604Minimum Time to Eat All Grains
2606Find the Substring With Maximum Cost
2607Make K-Subarray Sums Equal
2611Mice and Cheese
2645Minimum Additions to Make Valid String
2663Lexicographically Smallest Beautiful String
2673Make Costs of Paths Equal in a Binary Tree
2680Maximum OR
2697Lexicographically Smallest Palindrome
2706Buy Two Chocolates
2708Maximum Strength of a Group
2712Minimum Cost to Make All Characters Equal
2734Lexicographically Smallest String After Substring Operation
2769Find the Maximum Achievable Number
2772Apply Operations to Make All Array Elements Equal to Zero
2789Largest Element in an Array after Merge Operations
2790Maximum Number of Groups With Increasing Length
2813Maximum Elegance of a K-Length Subsequence
2819Minimum Relative Loss After Buying Chocolates
2825Make String a Subsequence Using Cyclic Increments
2835Minimum Operations to Form Subsequence With Target Sum
2842Count K-Subsequences of a String With Maximum Beauty
2844Minimum Operations to Make a Special Number
2847Smallest Number With Given Digit Product
2860Happy Students
2864Maximum Odd Binary Number
2868The Wording Game
2870Minimum Number of Operations to Make Array Empty
2871Split Array Into Maximum Number of Subarrays
2872Maximum Number of K-Divisible Components
2892Minimizing Array After Replacing Pairs With Their Product
2895Minimum Processing Time
2897Apply Operations on Array to Maximize Sum of Squares
2900Longest Unequal Adjacent Groups Subsequence I
2910Minimum Number of Groups to Create a Valid Assignment
2914Minimum Number of Changes to Make Binary String Beautiful
2918Minimum Equal Sum of Two Arrays After Replacing Zeros
2931Minimum Equal Sum of Two Arrays After Replacing Zeros
2939Maximum Xor Product
2952Minimum Number of Coins to be Added
2957Remove Adjacent Almost-Equal Characters
2971Find Polygon With the Largest Perimeter
3002Maximum Size of a Set After Removals
3003Maximize the Number of Partitions After Operations
3012Minimize Length of Array Using Operations
3014Minimum Number of Pushes to Type Word I
3016Minimum Number of Pushes to Type Word II
3022Minimize OR of Remaining Elements Using Operations
3035Maximum Palindromes After Operations
3068Find the Maximum Sum of Node Values
3074Apple Redistribution into Boxes
3075Maximize Happiness of Selected Children
3086Minimum Moves to Pick K Ones
3088Make String Anti-palindrome
3106Lexicographically Smallest String After Operations With Constraint
3107Minimum Operations to Make Median of Array Equal to K
3111Minimum Rectangles to Cover Points
3114Latest Time You Can Obtain After Replacing Characters
3119Maximum Number of Potholes That Can Be Fixed
3170Lexicographically Minimum String After Removing Stars
3189Minimum Moves to Get a Peaceful Board
3191Minimum Operations to Make Binary Array Elements Equal to One I
3192Minimum Operations to Make Binary Array Elements Equal to One II
3205Maximum Array Hopping Score I
3207Maximum Points After Enemy Battles
3216Lexicographically Smallest String After a Swap
3218Minimum Cost for Cutting Cake I
3219Minimum Cost for Cutting Cake II
3221Maximum Array Hopping Score II
3228Maximum Number of Operations to Move Ones to the End
3229Minimum Operations to Make Array Equal to Target
3239Minimum Number of Flips to Make Binary Grid Palindromic I
3240Minimum Number of Flips to Make Binary Grid Palindromic II
3273Minimum Amount of Damage Dealt to Bob
3282Reach End of Array With Max Score
3301Maximize the Total Height of Unique Towers
3302Find the Lexicographically Smallest Valid Sequence
3362Zero Array Transformation III
3397Maximum Number of Distinct Elements After Operations
3402Minimum Operations to Make Columns Strictly Increasing
3403Find the Lexicographically Largest String From the Box I
3406Find the Lexicographically Largest String From the Box II
3410Maximize Subarray Sum After Removing All Occurrences of One Element
3424Minimum Cost to Make Arrays Identical
3443Maximum Manhattan Distance After K Changes
3457Eat Pizzas!
3458Select K Disjoint Special Substrings
3462Maximum Sum With at Most K Elements
3468Find the Number of Copy Arrays
3474Lexicographically Smallest Generated String
3476Maximize Profit from Task Assignment
3478Choose K Elements With Maximum Sum
3480Maximize Subarrays After Removing One Conflicting Pair
3494Find the Minimum Amount of Time to Brew Potions
3495Minimum Operations to Make Array Elements Zero
3496Maximize Score After Pair Deletions
3499Maximize Active Section with Trade I
3501Maximize Active Section with Trade II
3506Find Time Required to Eliminate Bacterial Strains
3511Make a Positive Array
3517Smallest Palindromic Rearrangement I
3518Smallest Palindromic Rearrangement II
3523Make Array Non-decreasing
3542Minimum Operations to Convert All Elements to Zero
3545Minimum Deletions for At Most K Distinct Characters
3557Find Maximum Number of Non Intersecting Substrings
3576Transform Array to All Equal Elements
3587Minimum Adjacent Swaps to Alternate Parity
3627Maximum Median Sum of Subsequences of Size 3
3630Partition Array for Maximum XOR and AND
3633Earliest Finish Time for Land and Water Rides I
3635Earliest Finish Time for Land and Water Rides II
3638Maximum Balanced Shipments
3645Maximum Total from Optimal Activation Order
3675Minimum Operations to Transform String
3681Maximum XOR of Subsequences
3689Maximum Total Subarray Value I
3711Maximum Transactions Without Negative Balance
3720Lexicographically Smallest Permutation Greater Than Target
3723Maximize Sum of Squares of Digits
3724Minimum Operations to Transform Array
3727Maximum Alternating Sum of Squares
3730Maximum Calories Burnt from Jumps
3732Maximum Product of Three Elements After One Replacement
3734Lexicographically Smallest Palindromic Permutation Greater Than Target
3752Lexicographically Smallest Negated Permutation that Sums to Target
3763Maximum Total Sum with Threshold Constraints
3767Maximize Points After Choosing K Tasks
3776Minimum Moves to Balance Circular Array
3785Minimum Swaps to Avoid Forbidden Values
3796Find Maximum Value in a Constrained Sequence
3797Count Routes to Climb a Rectangular Grid
3806Maximum Bitwise AND After Increment Operations
3812Minimum Edge Toggles on a Tree
3816Lexicographically Smallest String After Deleting Duplicate Characters
3828Final Element After Subarray Deletions
3849Maximum Bitwise XOR After Rearrangement
3854Minimum Operations to Make Array Parity Alternating
3858Minimum Bitwise OR From Grid
3863Minimum Operations to Sort a String
3868Minimum Cost to Equalize Arrays Using Swaps
3888Minimum Operations to Make All Grid Elements Equal
3892Minimum Operations to Achieve At Least K Peaks
3897Maximum Value of Concatenated Binary Segments
3914Minimum Operations to Make Array Non Decreasing
3919Minimum Cost to Move Between Indices
3922Minimum Flips to Make Binary String Coherent
3947Maximum Number of Items From Sale II
3948Lexicographically Maximum MEX Array
3952Maximum Total Value of Covered Indices
3961Maximize Sum of Device Ratings
3964Minimum Lights to Illuminate a Road
3974Maximum Total Sum of K Selected Elements
3980Minimum Operations to Transform Binary String