classSolution { public: intsearch(vector<int>&nums, inttarget) { intleft=0; intright=nums.size()-1; while(left<=right){ intmid=(right-left)/2+left; intnum=nums[mid]; if (num==target){ returnmid; } if(num<target){ left=mid+1; } else{ right=mid-1; } } return-1; } };