Secondary Loop BS
Binary search as the inner step of an outer loop. The outer pass walks elements (or rows); for each one we bisect into a sorted structure. Total cost is O(N log M) - the loop times the search.
Bisect Derivatives
Loop one value, binary-search for its partner (complement, double, or matching boundary).
167. Two Sum II - Input Array Is Sorted
Medium·
Solutions:
FIG. 167 TWO SUM II INPUT ARRAY IS SORTED 2● INTERACTIVE
1855. Maximum Distance Between a Pair of Values
Medium·
Solutions:
FIG. 1855 MAXIMUM DISTANCE BETWEEN A PAIR OF VALUES 1● INTERACTIVE
1346. Check If N and Its Double Exist
Easy·
Solutions:
FIG. 1346 CHECK IF N AND ITS DOUBLE EXIST● INTERACTIVE
Bisect Derivatives in a 2D Matrix
Each row is independently sorted, so bisect row by row.
1351. Count Negative Numbers in a Sorted Matrix
Easy·
Solutions:
FIG. 1351 COUNT NEGATIVE NUMBERS IN A SORTED MATRIX● INTERACTIVE
1337. The K Weakest Rows in a Matrix
Easy·
Solutions:
FIG. 1337 THE K WEAKEST ROWS IN A MATRIX● INTERACTIVE
Intersection
Iterate the first array (or row), and binary-search every other one for the same value.
349. Intersection of Two Arrays
Easy·
Solutions:
FIG. 349 INTERSECTION OF TWO ARRAYS● INTERACTIVE
350. Intersection of Two Arrays II
Easy·
Solutions:
FIG. 350 INTERSECTION OF TWO ARRAYS II● INTERACTIVE
1198. Find Smallest Common Element in All Rows
Medium·
Solutions:
FIG. 1198 FIND SMALLEST COMMON ELEMENT IN ALL ROWS● INTERACTIVE
1213. Intersection of Three Sorted Arrays
Easy·
Solutions:
FIG. 1213 INTERSECTION OF THREE SORTED ARRAYS● INTERACTIVE
Custom Bisect
When the input is an opaque interface, hand-roll the bisect against its accessor.
1428. Leftmost Column with at Least a One
Medium·
Solutions:
FIG. 1428 LEFTMOST COLUMN WITH AT LEAST A ONE● INTERACTIVE