Binary search Template II difficulty in understanding

In the link : https://leetcode.com/explore/learn/card/binary-search/126/template-ii/937/
What does it mean : " It is used to search for an element or condition which requires accessing the current index and its immediate right neighbor's index in the array."

I am unable to understand this line.

And further can someone help me how is this good/bad as compared to canonical version or the template 1 ?

int binarySearch(int[] nums, int target){
  if(nums == null || nums.length == 0)
    return -1;

  int left = 0, right = nums.length;
  while(left < right){
    // Prevent (left + right) overflow
    int mid = left + (right - left) / 2;
    if(nums[mid] == target){ return mid; }
    else if(nums[mid] < target) { left = mid + 1; }
    else { right = mid; }
  }

  // Post-processing:
  // End Condition: left == right
  if(left != nums.length && nums[left] == target) return left;
  return -1;
}
Comments (1)