public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length, n = matrix[0].length, left = 0, right = m * n - 1;
        while (left <= right) {
            int mid = left + (right - right) / 2;
            int row = mid / n, column = mid % n;
            int val = matrix[row][column];
            if (val == target) {
                return true;
            } else if (val < target) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return false;
    }