DSA Tracker

Topic

Greedy interview questions

All 15 Greedy problems from the curated set, easiest first — a core topic for 3 of the 29 engineering roles.

Easy
3
Medium
12
Hard
0
Sheets
3
Watch the Greedy pattern solved step by step

What Greedy is

Updated 2026-09-09

A greedy algorithm makes the best-looking choice available right now, at every step, without ever looking back or second-guessing its decision. Think of a cashier making change by handing over the largest possible coin first, repeatedly, until the total is reached. Unlike dynamic programming, which saves and compares answers to multiple overlapping paths, a greedy strategy commits to one immediate option and keeps moving forward.

When to reach for it

Reach for greedy when problems ask for minimum jumps, interval scheduling, assigning resources to maximize satisfaction, or finding fractional values. Key signals include sorted orders where greedily taking the next item never hurts future options, or gas station round trips where running balances prove reachability. If you can prove that taking the immediate best choice never leaves you worse off than any alternative, greedy gives the fastest answer.

How to think about it

Start by sorting the input to bring the most promising candidates to the front. At each position, evaluate your local rule, take the best available piece, and update your running state. The crucial mental step is proving the greedy choice property: demonstrate that picking this immediate winner cannot block a better global solution down the road. If choosing an item now forces you to reconsider past decisions when conditions change later, greedy fails and you must switch to dynamic programming instead.

What each operation costs

OperationTime
sort elements to enable greedy selectionO(n log n)
greedy single-pass scan through sorted inputO(n)
greedy choice using a priority queueO(n log n)
What usually goes wrong
  • Applying a greedy choice without proving it yields the global optimum, such as picking the largest coin first for arbitrary denominations where dynamic programming was required.
  • Forgetting to sort the input before running the greedy loop, making local decisions on unordered elements that produce invalid answers.
  • Picking items based on only one attribute when the optimal decision depends on a ratio or combination of multiple attributes.

Every Greedy problem, easiest first

Roles that need Greedy

If you are targeting one of these, Greedy sits early in your path rather than being optional.

Track Greedy in your role's order

Pick your target role and all 370 problems resequence to what that interview actually asks. Free.

Start free

Greedy interview questions, answered

How many Greedy problems should I solve for interviews?

15 curated Greedy problems cover the patterns interviews repeat: 3 easy, 12 medium and 0 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.

Is Greedy actually asked in coding interviews?

Yes, though how much depends on the role. Greedy is a core topic for 3 of the 29 engineering roles tracked here, including Cloud Engineer, Robotics Engineer, Networking Engineer. For other roles it is lower frequency and belongs later in a study plan.

Which Greedy problem should I start with?

Start with Assign Cookies (Easy). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.

Other topics

Problem set and role mapping as of .