My solution on Java using DP
Open matrix from top to the bottom line by line, counting height of each column. Then check for each  column (only if it wasn't counted already) how many times 
Open matrix from top to the bottom line by line, counting height of each column. Then check for each  column (only if it wasn't counted already) how many times it appears to the right and to the left.  Area = (left+right)*height. Just pick the max one. Pretty fast\n\n    public class Solution {\n        public int maximalRectangle(char[][] matrix) {\n            int area = 0, new_area, r, l;\n            if(matrix.length > 0){\n                int[] line = new int[matrix[0].length];\n                boolean[] is_processed = new boolean[matrix[0].length];\n                for(int i = 0; i < matrix.length; i++){\n                    for(int j = 0; j < matrix[i].length; j++){\n                        if (matrix[i][j] == '1') {\n                            line[j]++;\n                            is_processed[j] = false;\n                        } else {\n                            line[j] = 0;\n                            is_processed[j] = true;\n                        }\n                    }\n                    for(int j = 0; j < matrix[i].length; j++){\n                        if(is_processed[j]) continue;\n                        r = l = 1;\n                        while((j + r < line.length)&&(line[j + r] >= line[j])){\n                            if(line[j + r] == line[j]) is_processed[j + r] = true;\n                            r++;\n                        }\n                        while((j - l >= 0)&&(line[j - l] >= line[j])) l++;\n                        new_area = (r + l - 1)*line[j];\n                        if (new_area > area) area = new_area;\n                    }\n                }\n            } return area;\n        }\n    }
[]