Python solution built off of Maximal Square [Time complexity: O(n^3)]
```class Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> int:\n        \n        if not matrix or not matrix[0]:\n            return 0\n  
```class Solution:\n    def maximalRectangle(self, matrix: List[List[str]]) -> int:\n        \n        if not matrix or not matrix[0]:\n            return 0\n        \n        m = len(matrix)\n        n = len(matrix[0])\n        \n        #prepping max squares array and finding largest value in array (max_num)\n\t\tmax_num = 1\n        for i in range(m):\n            matrix[i][0] = int(matrix[i][0])\n\n        for j in range(n):\n            matrix[0][j] = int(matrix[0][j])\n        \n        for i in range(1, m):\n            for j in range(1, n):\n                if matrix[i][j] == \'1\':\n                    tmp = min(matrix[i - 1][j], matrix[i][j - 1], matrix[i - 1][j - 1]) + 1\n                    matrix[i][j] = tmp\n                    max_num = max(max_num, tmp)\n                else:\n                    matrix[i][j] = 0\n    \n\t\t#initialize array for global longest chain of each number\n        max_values = [0 for i in range(max_num)]\n        \n        #iterate through rows to find longest chain of each value\n\t\tfor step in range(max_num):\n            for i in range(m):\n                curr_value = 0\n                for j in range(n):\n                    if matrix[i][j] > step:\n                        curr_value += 1\n                    else:\n                        if curr_value > max_values[step]:\n                            max_values[step] = curr_value\n                        curr_value = 0\n                if curr_value > max_values[step]:\n                    max_values[step] = curr_value\n            \n        #iterate through columns to find largest chain of each value\n        for step in range(max_num):\n            for j in range(n):\n                curr_value = 0\n                for i in range(m):\n                    if matrix[i][j] > step:\n                        curr_value += 1\n                    else:\n                        if curr_value > max_values[step]:\n                            max_values[step] = curr_value\n                        curr_value = 0\n                if curr_value > max_values[step]:\n                    max_values[step] = curr_value                \n                        \n        res = 0\n        \n\t\t#area of the rectangle can be calculated from neigboring squares\n        for s, count in enumerate(max_values):\n            if count != 0:\n                res = max(res, (s + 1) ** 2 + (s + 1) * (count - 1))\n        \n        return res
[]