81. Search in Rotated Sorted Array II

class Solution {
    public boolean search(int[] nums, int target) {
        if(nums.length==0)
            return false;
        int lo=0;
        int hi=nums.length-1;
        while(lohi)
        {
            int mid=(lo+hi)/2;
            if(nums[mid]==target)
                return true;
            if(nums[mid]nums[hi])
            {
                if(nums[lo]=targettargetnums[mid])
                    hi=mid;
                else
                    lo=mid+1;
            }
            else if(nums[mid]nums[hi])
            {
                if(nums[mid]targettarget=nums[hi])
                    lo=mid+1;
                else
                    hi=mid;
            }
            else
                hi--;
        }
        return nums[lo]==target;
    }
}

 

转载于:https://www.cnblogs.com/asuran/p/7600708.html

最新回复(0)
/jishux5s9ojFzItUs0N5u2Muq4c2zFGPz35QYzIV6OqgL1Mo_3D8