← Binary Search

Pattern Recognition Drill

#55 — Find peak element

Medium Binary Search

The Problem

Given an array where no two adjacent elements are equal, find any peak element.

What approach would you use?

Think about it before scrolling down.

Key Signals

Binary Search

Compare mid with mid+1. Move toward the larger side — a peak is guaranteed there. O(log n).

Common Trap

Linear scan finding max is O(n). Binary search works because you can always move toward a guaranteed peak.

← #54 #56 →