← All Patterns

Pattern Recognition Drill

#56

Medium Binary Search

The Problem

Given a rotated sorted array with unique elements, find the minimum element.

What approach would you use?

Think about it before scrolling down.

Min in rotated sorted array

Key Signals

Binary Search

Compare a[mid] with a[hi]. If a[mid] > a[hi], rotation point is right. O(log n).

Common Trap

Compare with a[hi] not a[lo]. Comparing with a[lo] doesn't reliably tell you which side the min is on.

← #55 #57 →