let length = nums.length;
    let j = 1; let key = nums[0];
    while(j < length && nums[j] > key){
        j++
    }
    if(target >= key && target <= nums[j-1]){
        return binarySearch(nums,target,0,j-1);
    }else{
        return binarySearch(nums,target,j,length-1);
    }

该题主要是利用数组的性质,降低复杂度。

  1. 找到数组转换的位置,会发现可以将其分为两个增序的部分
  2. 根据情况决定:是对前面部分进行二分还是后面部分。