We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
The array version is the easy half; the interview version is usually a variant - find the first/last occurrence, search a rotated array, or find a peak. The harder and more valuable form is binary searching the answer: when feasibility is monotonic, you can binary search the result even with no sorted array in sight. Watch the loop invariant and the mid calculation, which is where most candidates lose the plot under pressure.
A sorted input, or a monotonic "is this value feasible?" predicate you can binary search over.
19 problems. Each one runs in an in-browser editor against real test cases, with hints and a worked solution.
The patterns cheat sheet covers all of these in one page - what each one looks like in a problem statement, and the template that follows.