public int maximalRectangle(char[][] matrix) {
        int m = matrix.length;
        if (m == 0)
            return 0;
        int n = matrix[0].length;

        int[][] arr = new int[m][n];
        for (int j = 0; j < n; j++)
            if (matrix[0][j] == '1')
                arr[0][j] = 1;

        for (int i = 1; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (matrix[i][j] == '1') {
                    arr[i][j] = arr[i - 1][j] + 1;
                }
                else {
                    arr[i][j] = 0;
                }
            }
        }

        int max = 0;

        for (int[] it : arr) {
            max = Math.max(max, largestRectangleArea(it));
        }

        return max;

    }