Complete the code to start the binary search with the correct left boundary.
left := [1]The binary search starts from the first index, which is 0.
Complete the code to calculate the middle index correctly.
mid := left + (right - left) [1] 2
We divide the difference by 2 to find the middle index between left and right.
Fix the error in the condition to check if mid is a peak element.
if nums[mid] > nums[mid+[1]] {
We compare nums[mid] with the next element nums[mid+1] to decide the search direction.
Fill both blanks to update the search boundaries correctly.
if nums[mid] > nums[mid+[1]] { right = [2] } else { left = mid + 1 }
If nums[mid] is greater than nums[mid+1], the peak must be at mid or to the left, so we move the right boundary to mid.
Fill all three blanks to return the peak element index after the loop.
return [1] // The peak element index is at [2] or [3]
After the loop, left and right converge to the peak element index. Returning left is correct.