class Solution {
public:
bool searchMatrix(vector<vector<int> > &matrix, int target) {
int row=0,col=matrix[0].size()-1;
while(col>=0&&row<matrix.size())
{
if(target==matrix[row][col])return true;
else if(target<matrix[row][col])col--;
else row++;
}
return false;
}
};
网友评论