classSolution { public: intsearch(vector<int>& nums, int target){ int n = nums.size(); int left = 0, right = n - 1; while(left <= right){ int mid = left + (right - left >> 1); if(target == nums[mid]) return mid; elseif(target < nums[mid]) right = mid - 1; else left = mid + 1; } return-1; } };