Algorithms from zero
Sorting & search: interview drill
You understand binary search. Interviews test whether you can reach for it under a timer, cold, and explain the cost out loud.
Solve each problem before you reveal a hint, hit the target time, and narrate the time and space complexity 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 binary-search pattern 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
binary search
Follow-up (aloud)
Compute mid as lo + (hi - lo) // 2 rather than (lo + hi) // 2 — what bug does that avoid, and what is the loop invariant?
Follow-up (aloud)
Why is this O(log(m·n)) and not two separate O(log m)+O(log n) searches — and when would the two-step version be required instead?
Follow-up (aloud)
Why compare against nums[hi] rather than nums[lo]? Walk through what goes wrong if you pick the wrong anchor.
Follow-up (aloud)
Confirm this stays O(log n) despite the rotation, then describe how duplicates would degrade the worst case.
Follow-up (aloud)
State the complexity as O(n log m) and define n and m, then explain what makes a problem amenable to binary-search-on-answer at all.
Mark each problem solved once you finished it cold, inside the target time, and could state the complexity 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.