```
class Solution {
```

public:

bool searchMatrix(vector<vector<int> > &matrix, int target) {

```
int i=matrix.size()-1,j=0;
while(j<matrix[0].size()&&i>=0)
{
int x = matrix[i][j];
if(target==x) return 1;
if(target>x) j++;
else i--;
}
return 0;
}
```

};