class Solution { public: bool search(vector<int>& nums, int target) { int low=0; int high=nums.size()-1; //整个数组是分段递增的 while(low<high){ int mid=(low+high)/2; if(nums[mid]==target) return true; if(nums[mid]<nums[high]){//说明分界点在前半段,[mid,high]是递增的,但是[low,mid-1]是不是递增的我不确定 if(target<=nums[high]&&target>nums[mid]) low=mid+1; else high=mid-1; } else if(nums[mid]>nums[high]){ //说明分界点在后半段,[low,mid]是递增的,[mid+1,high]是不是递增的我不确定 if(target<nums[mid] && target>=nums[low]) high=mid-1; else low=mid+1; } else high--; } return nums[low]==target? true:false; } };