private static boolean search(int[][] matrix, int target) {
        if (matrix == null) return false;
        int height = matrix.length;
        if (height == 0) return false;
        int width = matrix[0].length;
        int columnIndex = width - 1;
        int rowIndex = 0;
        while (true) {
            int res = Arrays.binarySearch(matrix[rowIndex], 0, columnIndex + 1, target);
            if (res >= 0)
                return true;
            rowIndex++;
            if (rowIndex == height)
                return false;
            if (matrix[rowIndex][columnIndex] > target)
                columnIndex--;
            if (columnIndex < 0)
                return false;
        }
    }