awesome-everything RU
↑ Back to the climb

Algorithms from zero

Greedy & intervals: interview drill

Crux Timed greedy and interval problems from the NeetCode-150, with progressive hints — solve each cold, then narrate why the greedy choice is optimal.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 120 min

You understand the exchange argument. Interviews test whether you can spot the locally-optimal move under a timer, sort on the right key, and defend out loud why greedy stays optimal.

Goal

Solve each problem before you reveal a hint, hit the target time, and narrate the time and space complexity — and why the greedy choice is provably correct — as if an interviewer were listening. The hints exist for when you are genuinely stuck — they nudge you toward the pattern, never the full solution.

Five NeetCode-150 problems on the greedy and intervals patterns this unit teaches. Set a timer, solve each cold without looking at a hint, then say the time and space complexity out loud before you move on. Reveal a hint only when you are truly stuck — the hints nudge, they never hand you the answer.

0/5 solved

greedy

#53 Maximum SubarrayMedium15m
AmazonMeta
Follow-up (aloud)

State Kadane's invariant: what does the running value mean at each index, and why does carrying a negative prefix never help?

#55 Jump GameMedium15m
Amazon
Follow-up (aloud)

This greedy is O(n) one pass. Prove that tracking only the farthest reachable index never misses a valid path.

intervals

#57 Insert IntervalMedium15m
AmazonGoogle
Follow-up (aloud)

Because the input is pre-sorted, this is one linear pass. What is the overlap condition between two intervals, and where exactly do you test it?

#56 Merge IntervalsMedium15m
AmazonMeta
Follow-up (aloud)

The sort dominates the cost. State the overall complexity and why, after sorting, a single linear sweep suffices.

#435 Non-overlapping IntervalsMedium20m
AmazonGoogle
Follow-up (aloud)

Give the exchange argument for why 'keep the earliest-finishing interval' is optimal. What breaks if you sort by start instead?

Recap

Mark each problem solved once you finished it cold, inside the target time, and could justify the greedy choice without hesitation. Come back in a few days and re-solve the ones you marked — spaced revisits are what turn a recognised pattern into a reflex.

Continue the climb ↑Bit Manipulation as a Problem-Solving Tool
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.