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