```
bool searchMatrix(int** matrix, int matrixRowSize, int matrixColSize, int target) {
int r = 0, c = matrixColSize - 1;
while(r<matrixRowSize && c>=0) {
if(matrix[r][c] < target) r++;
else if (matrix[r][c] > target) c--;
else return true;
}
return false;
}
```