Skip to content

Greedy problems,
and the tell.

You can make a choice that looks best right now, and the problem asks for a maximum or a minimum. 233 problems in the catalogue carry this tag, from first-week easy to interview hard.

Free to start. Running and submitting a solution never costs credits.

How the pattern actually works.

One mechanism, and the mistake that costs people the problem.

The tell. You can make a choice that looks best right now, and the problem asks for a maximum or a minimum.

The mechanism. Pick the locally best option at each step and never reconsider. It only works when a swap argument holds: taking the greedy choice is never worse than any other first choice.

What goes wrong. Assuming greedy works because it passes the examples. If you cannot argue why the first choice is safe, the answer is usually dynamic programming.

The ones asked most often.

By how often the catalogue records them being set, not by our opinion.

  1. Valid Parenthesis StringMediumasked at 5 companies
  2. Maximum Performance of a TeamHardasked at 5 companies
  3. Minimum Deletions to Make Character Frequencies UniqueMediumasked at 3 companies
  4. Largest Palindromic NumberMediumasked at 3 companies
  5. Strong Password CheckerHardasked at 3 companies
  6. Construct String With Repeat LimitMediumasked at 2 companies
  7. House Robber IVMediumasked at 2 companies
  8. Largest Submatrix With RearrangementsMediumasked at 2 companies
  9. Minimum Cost of Buying Candies With DiscountEasyasked at 2 companies
  10. Sell Diminishing-Valued Colored BallsMediumasked at 2 companies

Read it, watch it, then solve it.

The order that makes a pattern stick.

Everything in the app, in one place.

Practice, interviews and the tools, all free to start. Swipe to see the rest.

Free to start: 100 AI credits when you sign up and 100 every month. Start free in the app

About greedy problems.

Free to start, no card.

Start practising
How do I know a problem is a greedy problem?

You can make a choice that looks best right now, and the problem asks for a maximum or a minimum.

How many greedy problems should I solve?

Enough to stop needing the hint, which is usually ten to fifteen across the levels, not the whole list. The catalogue tags 233, split roughly 18 easy, 137 medium and 45 hard in the sample we show, so work up rather than across.

What goes wrong most often in greedy problems?

Assuming greedy works because it passes the examples. If you cannot argue why the first choice is safe, the answer is usually dynamic programming.

Is practising by pattern better than a problem sheet?

A sheet tells you what to solve. A pattern tells you why those problems sit together, which is the part that carries over to the problem you have not seen. That is why the app files every problem under its pattern.