Complete the code to start binary search with the correct left index.
let mut left = [1];The binary search starts from the first index, which is 0.
Complete the code to calculate the middle index safely.
let mid = left + (right - left) [1] 2;
We divide the difference by 2 to find the middle index.
Fix the error in the condition to check if mid element is less than its right neighbor.
if nums[mid] [1] nums[mid + 1] {
We check if the middle element is less than the next element to decide search direction.
Fill both blanks to update the search boundaries correctly.
if nums[mid] [1] nums[mid + 1] { left = mid [2] 1; } else { right = mid; }
If mid element is less than next, move left to mid + 1 to search right half.
Fill all three blanks to return the peak index after binary search loop.
while left < right { let mid = left + (right - left) [1] 2; if nums[mid] [2] nums[mid + 1] { left = mid [3] 1; } else { right = mid; } } return left;
Divide by 2 to find mid, compare with <, and move left to mid + 1 if condition true.
