15 Core Greedy Patterns for Coding Interviews
Hey guyss! Be greedy to read this post.
The goal of this post is simple: bring together the most important greedy patterns in one place, with practice problems under each so that you can learn them the right way. If you go through these patterns one by one, you’ll notice that almost every greedy question you see in interviews fits neatly into one of them.
15 Greedy Patterns for Coding Interviews
Greedy algorithms look simple, but the real challenge is recognizing when they actually work.
Most students get confused because greedy problems come in many forms — intervals, sorting, tasks, graphs, heaps, arrays, strings — all looking unrelated.
But here’s the truth: Greedy problems follow a set of consistent patterns.
Once you master these patterns, you’ll instantly recognize them in interviews and solve them with confidence.
Below are the 15 essential Greedy Patterns you must know, along with
Practice Problems + Bonus Problems for each.
Pattern 1: Interval Scheduling
Sorting intervals by start/end and picking non-overlapping ones.
Practice Problems:
- Non-overlapping Intervals
- Merge Intervals
- Meeting Rooms II
- Minimum Number of Arrows to Burst Balloons
- Insert Interval
Bonus Problems:
Pattern 2: Fractional Knapsack
Pick items based on best value/weight ratio.
Practice Problems:
- Assign Cookies
- Candy
- Gas Station
- Minimum Number of Refueling Stops
- Minimized Maximum of Products Distributed to Any Store
Bonus Problems:
Pattern 3: Job Sequencing / Deadline Scheduling
Pick jobs by deadlines or profits.
Practice Problems:
Bonus Problems:
Pattern 4: Frequency Merging / Huffman-Type Greedy
Repeatedly combining items with smallest cost using a heap.
Practice Problems:
- Minimum Cost to Connect Sticks
- Reorganize String
- Sort Characters By Frequency
- Reduce Array Size to the Half
- Divide Array in Sets of K Consecutive Numbers
Bonus Problems:
Pattern 5: Coin Change (Greedy Variant)
Works only for canonical coin systems.
Practice Problems:
- Lemonade Change
- Minimum Moves to Reach Target With Rotations
- Count Operations to Obtain Zero
- Minimum Operations to Make Array Equal
- Minimum Deletions to Make Character Frequencies Unique
Bonus Problems:
Pattern 6: Sorting + Greedy Decision
Sort → apply greedy for optimal pairing/allocation.
Practice Problems:
- Queue Reconstruction by Height
- Boats to Save People
- Two City Scheduling
- Car Pooling
- Maximum Units on a Truck
Bonus Problems:
Pattern 7: Prefix/Suffix Greedy
Optimize based on prefix/suffix choices.
Practice Problems:
Bonus Problems:
Pattern 8: Priority Queue Greedy
Repeated greedy choice from dynamic set.
Practice Problems:
Bonus Problems:
Pattern 9: Greedy in Graph Algorithms
Greedy inside MST / shortest path logic.
Practice Problems:
- Network Delay Time
- Path With Minimum Effort
- Swim in Rising Water
- Minimum Cost to Connect All Points
- Cheapest Flights Within K Stops
Bonus Problems:
Pattern 10: Exchange Argument / Proof-Based Greedy
Used when greedy is not obvious.
Practice Problems:
Bonus Problems:
Pattern 11: Greedy Digit / Number Construction
Choosing digits/values step-by-step.
Practice Problems:
- Remove K Digits
- Monotone Increasing Digits
- Smallest Number at Given Digit Swaps
- Maximum Swap
- Next Greater Element III
Bonus Problems:
Pattern 12: Greedy String Construction
Pick best local character choice.
Practice Problems:
- Remove Duplicate Letters
- Smallest Subsequence of Distinct Characters
- Orderly Queue
- Lexicographically Smallest Equivalent String
- Longest Happy String
Bonus Problems:
Pattern 13: Optimal Partitioning
Divide array/string into optimal segments.
Practice Problems:
- Partition Labels
- String Compression II (has greedy inside)
- Minimum Length of String After Deleting Similar Ends
- Minimum Operations to Make the Array K-Increasing
- Split Array Largest Sum
Bonus Problems:
Pattern 14: Greedy Based on Parity / Contribution
Choose based on contribution to final score.
Practice Problems:
- Maximize Sum of Array After K Negations
- Minimize Maximum Pair Sum in Array
- Maximum Score From Removing Stones
- Minimum Operations to Halve Array Sum
- Minimize Sum of Distances in Array
Bonus Problems:
Pattern 15: Greedy Selection With Constraints
Pick best option allowed by constraints (capacity, balance, conditions).
Practice Problems:
- Maximum Score From Performing Multiplication Operations
- Jump Game VI
- Maximum Bags With Full Capacity of Rocks
- Split a String Into the Max Number of Unique Substrings
- Longest Happy Prefix
Bonus Problems:
Would love to indulge your patterns, Qns and add-ons, do share your thoughts!
If you found this post useful please upvote.
Happy Coding!!
Links to my other shares you might find useful:
Complete Plan (1st yr-3rd yr) (DSA + Projects + Core CS)
10 Sliding Window Patterns For Coding Interviews
15 DP variations for Interviews
Amazon ❤️ Trees; Google ❤️ Graphs; Microsoft ❤️ DP; Meta ❤️ fusion => interviewers ❤️ DSA
10 N-ary Tree Problems For Interviews That Define Google-Level Thinking

