```
public boolean searchMatrix(int[][] matrix, int target) {
int row = matrix.length;
int col = matrix[0].length;
int i = 0;
int j = row * col-1;
int mid = i+(i-j)/2;
while(i <= j){
int mid_val = matrix[mid/col][mid%col];
if(target == mid_val) return true;
if(target < mid_val){
j = mid-1;
}else{
i = mid+1;
}
mid = i+(i-j)/2;
}
return false;
}
```

I think i wrote pretty clear and really dont know why run time error thnks