Concept Flow - Find Peak Element Using Binary Search
Start with array boundaries: left=0, right=n-1
Calculate mid = (left+right)/2
Compare nums[mid
mid
Move right boundary to mid
Move left boundary to mid+1
Repeat until left == right
Return left as peak index
We repeatedly check the middle element and compare it with its right neighbor to decide which half contains a peak, narrowing the search until we find a peak.