Complete the code to start the binary search with the correct initial left index.
int left = [1];The left pointer should start at index 0 to cover the entire array.
Complete the code to calculate the middle index correctly.
int mid = left + ([1] - left) / 2;
We calculate mid as left plus half the distance to right to avoid overflow.
Fix the error in the condition to check if the left half is sorted.
if (nums[left] [1] nums[mid]) {
The left half is sorted if nums[left] is less than or equal to nums[mid].
Fill both blanks to update the search boundaries when the target is in the left sorted half.
if (target [1] nums[mid] && target [2] nums[left]) { right = mid - 1; } else { left = mid + 1; }
The target must be less than mid and greater than or equal to left to be in the left half.
Fill all three blanks to update the search boundaries when the right half is sorted.
if (target [1] nums[right] && target [2] nums[mid]) { left = mid + 1; } else { right = mid - [3]; }
The target must be greater than or equal to mid and less than or equal to right to be in the right half. We subtract 1 from right to narrow the search.
