DSA question set · 197 questions
Greedy DSA Practice Questions
Explore 197 DSA questions in Greedy. Practice with DSAWiser’s code editor and visualizer.
GreedyMathStringsArraysSortingTwo PointersHeap (Priority Queue)StackCountingHash TableDynamic ProgrammingBinary Indexed TreeMonotonic StackSliding WindowBinary SearchQueueUnion FindGraphMatrix
What’s in this set
The Greedy collection contains 197 problems: 50 basic, 52 easy, 54 medium, 21 hard, 20 very hard. Choose a question at your current level, or follow the collection’s order below.
Topics in this collection include Greedy, Math, Strings, Arrays, Sorting. Each question shows its own topics and difficulty so you can decide where to begin.
Practice with the code visualizer
- Open a question in the editor and read the statement, inputs, and expected output. Predict the result for a small example before writing code.
- Write a solution and run the examples. If a result differs from your prediction, reduce the input until you can follow each step.
- Step through your code in the visualizer. Use a breakpoint to inspect the state at a specific line, then compare it with your reasoning.
Questions in this set
197 totalOpen a question in the editor to read its statement and examples. Sign in to practice.
- Larger of Two NumbersGreedy · MathBasic
- Cheaper of Two PricesGreedy · MathBasic
- Enough Money?Greedy · MathBasic
- Pick the Bigger GiftGreedy · StringsBasic
- Match WinnerGreedy · StringsBasic
- Height LimitGreedy · MathBasic
- One BonusGreedy · MathBasic
- Repeated Better OptionGreedy · MathBasic
- Heavier BasketGreedy · ArraysBasic
- Discount PriceMathBasic
- Coins of 1, 2 and 5Greedy · MathBasic
- Coins of 1, 5, 10 and 25Greedy · MathBasic
- Count Every CoinGreedy · Math · ArraysBasic
- Banknotes of 1, 5, 10, 50 and 100Greedy · MathBasic
- Take While You CanGreedy · ArraysBasic
- Counting Sock PairsArrays · MathBasic
- Same-Price CandiesGreedy · MathBasic
- Largest Number from DigitsGreedy · Sorting · MathBasic
- Smallest Number from DigitsGreedy · Sorting · MathBasic
- Climbing Stairs (1 or 2)Greedy · MathBasic
- Frog Jumps (1, 2 or 3)Greedy · MathBasic
- Weekly SavingsGreedy · ArraysBasic
- Sticker AlternationGreedy · ArraysBasic
- Rope PiecesGreedy · MathBasic
- Two Items, One BudgetGreedy · MathBasic
- Maximum of the ListArraysBasic
- Minimum of the ListArraysBasic
- Record-Breaking DaysArraysBasic
- Hotter Than YesterdayArraysBasic
- Longest Same-Value StretchArraysBasic
- Longest Warm StretchGreedy · ArraysBasic
- Always the Better OptionGreedy · ArraysBasic
- Range of the ListArraysBasic
- Peaks in the RowArraysBasic
- Increasing PrefixArraysBasic
- Best Trade DayGreedy · ArraysBasic
- Longest Run of Even NumbersArraysBasic
- Best Pair of NeighborsGreedy · ArraysBasic
- Score Reset GameGreedy · ArraysBasic
- Safe SpendingGreedy · ArraysBasic
- Order Two TasksGreedy · MathBasic
- Merge Two Sorted ListsTwo Pointers · ArraysBasic
- Sum of the k LargestGreedy · Sorting · ArraysBasic
- Cheapest PairGreedy · ArraysBasic
- Both Take the LargestGreedy · Sorting · ArraysBasic
- Two Boxes, First FitGreedy · ArraysBasic
- One Free PurchaseGreedy · ArraysBasic
- Watering the GardenGreedy · MathBasic
- Maximum ItemsGreedy · Sorting · ArraysBasic
- Take the Larger EndGreedy · Two Pointers · ArraysBasic
- Cookie GiveawayGreedy · Two Pointers · Arrays · SortingEasy
- Profit from Every RiseGreedy · ArraysEasy
- Lemonade StandGreedy · ArraysEasy
- Two Teams SplitGreedy · Sorting · ArraysEasy
- Rescue RaftsGreedy · Two Pointers · Arrays · SortingEasy
- Movie MarathonGreedy · Sorting · ArraysEasy
- One Screen, Few CancellationsGreedy · Sorting · ArraysEasy
- Shortest Job FirstGreedy · Sorting · ArraysEasy
- Tandem BicyclesGreedy · Sorting · ArraysEasy
- Pair and Sum the SmallerGreedy · Sorting · ArraysEasy
- Flower Bed SpacingGreedy · ArraysEasy
- Matching SeatsGreedy · Sorting · ArraysEasy
- Mice and HolesGreedy · Sorting · ArraysEasy
- Chocolate PacksGreedy · Sorting · ArraysEasy
- Buy Two ChocolatesGreedy · Sorting · ArraysEasy
- Largest Perimeter TriangleGreedy · Sorting · Arrays · MathEasy
- Sign FlipsGreedy · Sorting · ArraysEasy
- Up-Down SignatureGreedy · Two Pointers · Strings · ArraysEasy
- One Digit UpgradeGreedy · MathEasy
- Largest Odd Tail NumberGreedy · Strings · MathEasy
- Messy ColumnsGreedy · Arrays · StringsEasy
- Joining RopesGreedy · Heap (Priority Queue) · ArraysEasy
- Fractional LootGreedy · Sorting · ArraysEasy
- All Papers on TimeGreedy · Sorting · ArraysEasy
- Sorting by PiecesGreedy · ArraysEasy
- Pairs Under the LimitTwo Pointers · ArraysEasy
- Calm PartnersGreedy · Two Pointers · Sorting · ArraysEasy
- Just Enough Fuel StopsGreedy · ArraysEasy
- Fixing the BracketsGreedy · Strings · StackEasy
- Gathering the ChipsGreedy · Math · ArraysEasy
- Candy Shop OfferGreedy · Sorting · ArraysEasy
- Splitting a Balanced LineGreedy · Strings · CountingEasy
- Smallest RearrangementGreedy · Sorting · StringsEasy
- Alternating LightsGreedy · ArraysEasy
- Two Sum, SortedTwo Pointers · ArraysEasy
- One Calendar CheckGreedy · Sorting · ArraysEasy
- Largest Number from Length and SumGreedy · Math · StringsEasy
- Smallest Number from Length and SumGreedy · Math · StringsEasy
- Level the StepsGreedy · ArraysEasy
- Minimizing the Product SumGreedy · Sorting · ArraysEasy
- Trees with Elbow RoomGreedy · Sorting · ArraysEasy
- Take the Bigger HalfGreedy · Sorting · ArraysEasy
- Close PairsGreedy · Sorting · Two Pointers · ArraysEasy
- Zigzag OrderGreedy · Sorting · ArraysEasy
- Meet in the MiddleMath · Sorting · ArraysEasy
- Building the Longest PalindromeGreedy · Hash Table · StringsEasy
- Keep the Best of Each RunGreedy · Strings · ArraysEasy
- Jobs Before Their DeadlinesGreedy · Sorting · ArraysEasy
- Digits That Never FallGreedy · MathEasy
- Taxi FleetGreedy · Sorting · Two Pointers · ArraysEasy
- Rain BarrelsGreedy · Dynamic Programming · StringsEasy
- Three Piles of StonesGreedy · MathEasy
- Circular Fuel TourGreedy · ArraysMedium
- Can You Cross the Swamp?Greedy · Arrays · Dynamic ProgrammingMedium
- Text SegmentsGreedy · Two Pointers · Strings · Hash TableMedium
- Arrow RainGreedy · Sorting · ArraysMedium
- Task CooldownGreedy · Sorting · Counting · Hash TableMedium
- Fewest Jumps AcrossGreedy · Arrays · Dynamic ProgrammingMedium
- Queue ReformationGreedy · Binary Indexed Tree · Sorting · ArraysMedium
- Energy CardsGreedy · Two Pointers · Sorting · ArraysMedium
- Stitching the FilmGreedy · Dynamic Programming · ArraysMedium
- Biggest ConcatenationGreedy · Sorting · StringsMedium
- Runs of K CardsGreedy · Sorting · Arrays · Hash TableMedium
- No Double LettersGreedy · Heap (Priority Queue) · Strings · CountingMedium
- Fewest RoomsGreedy · Sorting · Heap (Priority Queue) · ArraysMedium
- Erase DigitsGreedy · Stack · Monotonic Stack · StringsMedium
- Bracket WildcardsGreedy · Strings · Dynamic Programming · StackMedium
- Rotate the DominoesGreedy · ArraysMedium
- Bus LoadGreedy · Arrays · SortingMedium
- Garden TapsGreedy · Dynamic Programming · ArraysMedium
- Clean CutsGreedy · Hash Table · StringsMedium
- Removing the RaritiesGreedy · Hash Table · Sorting · ArraysMedium
- Gathering the OnesGreedy · Sliding Window · ArraysMedium
- Ladders and BricksGreedy · Heap (Priority Queue) · ArraysMedium
- The Broken CalculatorGreedy · MathMedium
- One Swap WonderGreedy · MathMedium
- Best CrewGreedy · Sorting · ArraysMedium
- Trimming the EndsGreedy · Two Pointers · StringsMedium
- One Fix SortGreedy · ArraysMedium
- Splitting Into Even PartsGreedy · MathMedium
- Happiest DinersGreedy · Sorting · ArraysMedium
- Building the Target TripletGreedy · ArraysMedium
- Biggest Cake PieceSorting · ArraysMedium
- Prize SelectionGreedy · Hash Table · Sorting · ArraysMedium
- Pancake ChefGreedy · Two Pointers · Sorting · ArraysMedium
- Car ConvoysGreedy · Sorting · Arrays · Monotonic StackMedium
- Digit RiddleGreedy · Stack · StringsMedium
- Finish the ChantGreedy · StringsMedium
- Gift BasketsGreedy · Sorting · ArraysMedium
- Merge Time BlocksGreedy · Sorting · ArraysMedium
- Making Frequencies UniqueGreedy · Sorting · Strings · Hash TableMedium
- Strict Zigzag OrderGreedy · Sorting · ArraysMedium
- Scenic Photo PairGreedy · Arrays · Dynamic ProgrammingMedium
- Counting Positive PrefixesGreedy · Sorting · ArraysMedium
- Marking the IndicesGreedy · Two Pointers · Sorting · ArraysMedium
- Leveling the PeaksGreedy · ArraysMedium
- Marble BagsGreedy · Sorting · ArraysMedium
- Distant RepeatsGreedy · Heap (Priority Queue) · Strings · Hash TableMedium
- Task Reordering EnergyGreedy · Sorting · ArraysMedium
- Field BloomGreedy · Sorting · ArraysMedium
- Cake Cutting CostsGreedy · Sorting · ArraysMedium
- Largest Multiple of ThreeGreedy · Dynamic Programming · ArraysMedium
- Largest MergeGreedy · Two Pointers · StringsMedium
- Diminishing TreasureGreedy · Binary Search · Sorting · Arrays · MathMedium
- Fair Weighted LevellingGreedy · Binary Search · Sorting · ArraysMedium
- Longest Chunked PalindromeGreedy · Two Pointers · Dynamic Programming · StringsMedium
- Event MarathonGreedy · Heap (Priority Queue) · Arrays · SortingHard
- Course Deadline CrunchGreedy · Heap (Priority Queue) · Arrays · SortingHard
- Fuel RefitsGreedy · Heap (Priority Queue) · Arrays · Dynamic ProgrammingHard
- Team PerformanceGreedy · Heap (Priority Queue) · Arrays · SortingHard
- Venture CapitalGreedy · Heap (Priority Queue) · Arrays · SortingHard
- Money Before TradingGreedy · Sorting · ArraysHard
- Computer RuntimeGreedy · Binary Search · Arrays · SortingHard
- Value PatchingGreedy · ArraysHard
- K Consecutive FlipsGreedy · Queue · Sliding Window · ArraysHard
- Latest Possible TasksGreedy · Sorting · ArraysHard
- Smallest Range Across ListsGreedy · Heap (Priority Queue) · Sliding Window · ArraysHard
- Two Rows, One Giant NumberGreedy · Monotonic Stack · Stack · ArraysHard
- Digit RansomGreedy · Binary Indexed Tree · StringsHard
- Sorting by Pieces IIGreedy · Monotonic Stack · Sorting · ArraysHard
- Couples at the PartyGreedy · Union Find · Graph · ArraysHard
- Rearranging FruitsGreedy · Hash Table · Sorting · ArraysHard
- Palindrome by Adjacent SwapsGreedy · Two Pointers · Binary Indexed Tree · StringsHard
- Washers in a RowGreedy · ArraysHard
- Meeting Rooms, NumberedGreedy · Heap (Priority Queue) · Sorting · ArraysHard
- Best Meeting SquareSorting · Math · MatrixHard
- Fair BonusesGreedy · ArraysHard
- Raising the TerracesGreedy · ArraysVery hard
- Snapping the ReedsGreedy · Arrays · MathVery hard
- Voltage BandGreedy · Heap (Priority Queue) · ArraysVery hard
- Battery Chore QueueGreedy · Sorting · ArraysVery hard
- Reverse-Built WallGreedy · Heap (Priority Queue) · ArraysVery hard
- Elegant SouvenirsGreedy · Sorting · Heap (Priority Queue) · ArraysVery hard
- Wage-Fair CrewGreedy · Sorting · Heap (Priority Queue) · ArraysVery hard
- Twin WitnessesGreedy · Sorting · ArraysVery hard
- Shared Break WindowsGreedy · Sorting · ArraysVery hard
- Three-Way Sheet MergeGreedy · Heap (Priority Queue) · ArraysVery hard
- Two-Station AssemblyGreedy · Sorting · ArraysVery hard
- Cheapest Road NetworkGreedy · Union Find · Sorting · GraphVery hard
- Cheapest Delivery RouteGreedy · Heap (Priority Queue) · GraphVery hard
- Watchtowers in the CanopyGreedy · Graph · ArraysVery hard
- Busiest Delivery HallsGreedy · Heap (Priority Queue) · ArraysVery hard
- K Consecutive LanternsGreedy · Sliding Window · Math · ArraysVery hard
- Skyline of the Festival TentsGreedy · Heap (Priority Queue) · Sorting · ArraysVery hard
- Server Hall DispatchGreedy · Heap (Priority Queue) · ArraysVery hard
- Typeset the ScrollGreedy · Strings · ArraysVery hard
- Bracket Mountain PeaksGreedy · Strings · SortingVery hard