```
public class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
int row = 0;
int start = 0;
int end = (matrix.length*matrix[0].length)-1;
int colLength = matrix[0].length;
while(start<=end){
int mid = (start+end)/2;
int tempRow = (mid/colLength);
int tempCol = (mid%colLength);
if(matrix[tempRow][tempCol] == target) return true;
if(matrix[tempRow][tempCol]<target){
start=mid+1;
}else{
end = mid-1;
}
}
return false;
}
}
```