在转动过得有序数组中寻找目标值
在转动过的有序数组中寻找目标值
https://www.nowcoder.com/practice/7cd13986c79d4d3a8d928d490db5d707?tpId=117&tags=&title=&diffculty=0&judgeStatus=0&rp=1&tab=answerKey
public int search (int[] A, int target) { if(A==null) return -1; int left = 0; int right = A.length-1; //不存在重复 while (left<=right){ int mid = (right-left)/2+left; if (A[mid]==target) return mid; else if(A[mid]<A[right]){ if (target>A[mid] && target<=A[right]){ left = mid+1; }else { right= mid-1; } }else { if(target>=A[left] && target<A[mid]){ right = mid-1; }else { left = mid+1; } } } return -1; }