162. Find Peak Element

Description

Here

Intuition

Using binary search

The invariant that holds: if left < mid < mid + 1 < right:

  1. if nums[mid] < nums[mid + 1], it's guaranteed to have one local max in [mid + 1, right]
  2. if nums[mid] > nums[mid + 1], it's guaranteed to have one local max in [left, mid]

Solution

Solution

results matching ""

    No results matching ""