[EXPLANATION] Runtime beats 92.59%
Intuition\nConvert each row of the matrix into a histogram of heights, where each height represents the count of consecutive 1s up to that row. This allows us t
# Intuition\nConvert each row of the matrix into a histogram of heights, where each height represents the count of consecutive 1s up to that row. This allows us to apply the largest rectangle in a histogram technique to find the maximal rectangle of 1s in the matrix.\n\n# Approach\nFor each row, update histogram heights based on consecutive 1s.\n\nUse a stack to find the largest rectangle in the histogram for each row, updating the maximum area as you go.\n\n# Complexity\n- Time complexity:\nO(rows * cols): We update the histogram and compute the maximal rectangle area for each row.\n\n- Space complexity:\nO(cols): We use an array for heights and a stack, both proportional to the number of columns.\n\n# Code\n```typescript []\nfunction maximalRectangle(matrix: string[][]): number {\n    if (matrix.length === 0) return 0;\n    \n    const rows = matrix.length;\n    const cols = matrix[0].length;\n    const heights = new Array(cols).fill(0);\n    let maxArea = 0;\n    \n    for (let i = 0; i < rows; i++) {\n        for (let j = 0; j < cols; j++) {\n            // Update heights array\n            heights[j] = matrix[i][j] === \'1\' ? heights[j] + 1 : 0;\n        }\n        // Calculate the maximal rectangle area for the current row (histogram)\n        maxArea = Math.max(maxArea, largestRectangleArea(heights));\n    }\n    \n    return maxArea;\n}\n\nfunction largestRectangleArea(heights: number[]): number {\n    const stack: number[] = [];\n    let maxArea = 0;\n    heights.push(0); // Sentinel to ensure all heights are processed\n    \n    for (let i = 0; i < heights.length; i++) {\n        while (stack.length > 0 && heights[i] < heights[stack[stack.length - 1]]) {\n            const height = heights[stack.pop()!];\n            const width = stack.length === 0 ? i : i - stack[stack.length - 1] - 1;\n            maxArea = Math.max(maxArea, height * width);\n        }\n        stack.push(i);\n    }\n    \n    return maxArea;\n}\n\n```
['TypeScript']