~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Binary search on the answer
Monotonic feasibility check + search the smallest value that works.
Main path: 7 problems, about 3 hours.
Notes
Recognise it when: the question is "minimum capacity / speed / time such that X is possible", feasibility is monotone in the answer, and checking one candidate is easy (a greedy O(n) check).
def feasible(cap):
days, load = 1, 0
for w in weights:
if load + w > cap: days, load = days + 1, 0
load += w
return days <= D
lo, hi = max(weights), sum(weights)
while lo < hi:
mid = (lo + hi) // 2
if feasible(mid): hi = mid
else: lo = mid + 1
return lo
Gotchas: pick bounds that are definitely infeasible or feasible (lo = the tightest lower bound). Use integer ceiling division, -(-a // b). For "maximum such that", flip the logic.
11 problems
Interview roadmap
Binary search Sorted lookups, rotations, searching the answer.
Binary search on the answer guide
- Play first: The Hungry Boss 1-minute game Binary search on the answer
- Smallest value that passes a check basics py · c++ · java easy
- Biggest square cookies py · c++ · java medium
- Sqrt(x) py · c++ · java easy
- Koko Eating Bananas code the boss py · c++ · java medium
- Capacity to Ship Packages Within D Days py · c++ · java medium
- Earliest time to build t products py · c++ · java medium
- Split Array Largest Sum py · c++ · java hard
More practice: 4 problems
- Maximum Throughput SnowflakeTwo Sigma py · c++ · java medium
- Find Median In Large Array AirbnbGoogle py · c++ · java medium
- Maximize portfolio floor value Uber py · c++ · java medium
- Distributed mode and median under a bandwidth budget assessment 3 levels Anthropic py · c++ · java hard