← Back to TypeScript
Search and Intervals
Binary search and the interval merge — precision problems where the whole exercise is the boundary, and one off comparison decides everything.
Binary search boundaries
intermediateblankComplete the classic binary search — the bounds, the loop condition, and the midpoint that everything else leans on.
Challenge: the insertion index
intermediatechallengeReturn where a value belongs in a sorted array — the count of elements strictly smaller — with a half-open binary search.
Challenge: merge overlapping intervals
advancedchallengeCollapse a list of intervals into the disjoint set — sort by start, then sweep once.
Review: the merge that loses coverage
intermediatereviewAn interval merge handles every overlap the tests throw at it, then silently shrinks a window that contained a smaller one. Find the line that overwrites instead of extending.