class Solution {
public:
bool searchMatrix(vector<vector<int>>& matrix, int target) {
int r = matrix.size()-1;
if(r<0) return false;
int c = matrix[0].size()-1;
if(c<0) return false;
while(matrix[r][0]>target)
{
r--;
if(r<0) return false;
}
while(matrix[r][c] != target)
{
c--;
if(c<0) return false;
}
return true;
}
};