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.
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.
Sorting intervals by start/end and picking non-overlapping ones.
Practice Problems:
Bonus Problems:
Pick items based on best value/weight ratio.
Practice Problems:
Bonus Problems:
Pick jobs by deadlines or profits.
Practice Problems:
Bonus Problems:
Repeatedly combining items with smallest cost using a heap.
Practice Problems:
Bonus Problems:
Works only for canonical coin systems.
Practice Problems:
Bonus Problems:
Sort → apply greedy for optimal pairing/allocation.
Practice Problems:
Bonus Problems:
Optimize based on prefix/suffix choices.
Practice Problems:
Bonus Problems:
Repeated greedy choice from dynamic set.
Practice Problems:
Bonus Problems:
Greedy inside MST / shortest path logic.
Practice Problems:
Bonus Problems:
Used when greedy is not obvious.
Practice Problems:
Bonus Problems:
Choosing digits/values step-by-step.
Practice Problems:
Bonus Problems:
Pick best local character choice.
Practice Problems:
Bonus Problems:
Divide array/string into optimal segments.
Practice Problems:
Bonus Problems:
Choose based on contribution to final score.
Practice Problems:
Bonus Problems:
Pick best option allowed by constraints (capacity, balance, conditions).
Practice Problems:
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