Algorithms & Data Structures
Intermediate
Pro
Binary Search
Halve the search space to turn linear scans into logarithmic-time solutions
45 min read
0 views
Learn the classic binary search template and its off-by-one traps, then generalize the idea to 'binary search on the answer' over monotonic predicates. Covers rotated arrays, medians of two arrays, matrix search, peak finding, and weighted sampling.