#include <asm-generic/errno.h> class Solution { public: int search(vector<int>& nums, int target) { if(nums.empty()) return -1; int left=0,right=nums.size()-1; int dex=-1; int mid=(left+right)/2; while(left<right) { if(nums[mid]>target) right=mid; else if(nums[mid]==target) break; else left=mid+1; mid=(left+right)/2; } if(nums[mid]==target) dex=mid; return dex; } };