Pyrhon O(n^2) solution based on Largest Rectangle in Histogram
class Solution:\n    # @param matrix, a list of lists of 1 length string\n    # @return an integer\n    def maximalRectangle(self, matrix):\n        if not matr
    class Solution:\n    # @param matrix, a list of lists of 1 length string\n    # @return an integer\n    def maximalRectangle(self, matrix):\n        if not matrix:\n            return 0\n        h, w = len(matrix), len(matrix[0])\n        m = [[0]*w for _ in range(h)]\n        for j in range(h):\n            for i in range(w):\n                if matrix[j][i] == '1':\n                    m[j][i] = m[j-1][i] + 1\n        return max(self.largestRectangleArea(row) for row in m)\n\n    def largestRectangleArea(self, height):\n        height.append(0)\n        stack, size = [], 0\n        for i in range(len(height)):\n            while stack and height[stack[-1]] > height[i]:\n                h = height[stack.pop()]\n                w = i if not stack else i-stack[-1]-1\n                size = max(size, h*w)\n            stack.append(i)\n        return size\n\nm is every row height, it is easy to convert this to Largest Rectangle in Histogram
['Python']