```
public boolean searchMatrix(int[][] matrix, int target) {
boolean found = false;
int rows = matrix.length;
int columns = matrix[0].length;
int curRow = 0;
int curCol = columns - 1;
while (curRow < rows && curCol >= 0) {
if(matrix[curRow][curCol]==target)//curRow*columns+curCol
{
found =true;
break;
}
else if(matrix[curRow][curCol]<target){
curRow++;
}
else {
curCol--;
}
}
return found;
}
```