public int maximalRectangle(char[][] matrix) {
        if (matrix == null || matrix.length == 0)
            return 0;
        int[][] A = new int[matrix.length][matrix[0].length];
        for (int i = 0; i < matrix[0].length; i++)
            A[0][i] = matrix[0][i] == '1' ? 1 : 0;
        for (int i = 1; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                A[i][j] = matrix[i][j] == '1' ? A[i - 1][j] + 1 : 0;
            }
        }
        int area = 0;
        for (int i = 0; i < matrix.length; i++) {
            area = Math.max(area, largestRectangleArea(A[i]));
        }
        return area;
    }