33. Search in Rotated Sorted Array

public class Solution {
    public int search(int[] nums, int target) {
        int start=0,end=nums.length-1;
        while(startnums[end]){
               if(target=nums[start]) end=mid-1;
               else start=mid+1;
           }else{
               if(target>nums[mid]&&target<=nums[end]) start=mid+1;
               else end=mid-1;
           }
        }
        return nums[start]==target?start:-1;
    }
}

你可能感兴趣的:(33. Search in Rotated Sorted Array)