// 68ms size 返回的是无符号整数,和负数比较时序特别注意转换
1 class Solution { 2 public: 3 bool searchMatrix(vector<vector<int> > &matrix, int target) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 int i=-1; 7 for(;i<(int)(matrix.size()-1);i++) 8 { 9 if(target<matrix[i+1][0]) 10 break; 11 } 12 if(i==-1) 13 { 14 return false; 15 } 16 vector<int>::iterator p; 17 p=find(matrix[i].begin(),matrix[i].end(),target); 18 if(p!=matrix[i].end()) 19 return true; 20 else 21 return false; 22 } 23 };