Skip to content
core-pattern

Modified Binary Search

Use binary search for ordered lookup, boundaries, rotated arrays, peaks, and monotonic partitions.

Problems

Problems in Modified Binary Search

Practice problems that share this primary solution pattern and compare the clues that reveal it.

High-tech laboratory equipment with computer system in lab setting.
beginner
10 min read

Search Insert Position

This problem asks for more. If the target is absent, return the index where it could be inserted while keeping the array sorted.

View solution
Lush green water plants float in a serene pool at Meise Botanical Garden, Belgium.
expert
14 min read

Median of Two Sorted Arrays

Merging is the obvious solution. It is also disqualified by the runtime requirement. The useful reframe is to search for a cut, not for a value: place…

View solution
Businesswoman working on laptop with Android 6.0 Marshmallow webpage open.
intermediate
10 min read

Search a 2D Matrix

A matrix can be two-dimensional storage with a one-dimensional search space. Prove that shape first, then run ordinary binary search over virtual indices.

View solution