public class Solution {

```
public boolean searchMatrix(int[][] matrix, int target) {
if(matrix == null) return false;
int rowLen = matrix.length, colLen = matrix[0].length;
if(target < matrix[0][0] || target > matrix[rowLen - 1][colLen - 1]) return false;
int index = -1;
for(int i=0; i<rowLen; i++){
if(matrix[i][0] <= target && matrix[i][colLen - 1] >= target){index = i; break;}
else continue;
}
if(index == -1) return false;
for(int j=0; j<colLen; j++)
if(target == matrix[index][j]) return true;
return false;
}
```

}