classSolution { public: intsearchInsert(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; } elseif(num<target){ left=mid+1; } elseif(num>target){ right=mid-1; } } returnleft; } };