Hard · Dynamic Programming
Maximal Rectangle
Given a rows × cols binary matrix filled with the characters '0' and '1', return the area of the largest axis-aligned rectangle that contains only '1's.
Examples
Example 1
{
"matrix": [
["1", "0", "1", "0", "0"],
["1", "0", "1", "1", "1"],
["1", "1", "1", "1", "1"],
["1", "0", "0", "1", "0"]
]
}Output: area 6
Example 2
{
"matrix": [
["1", "1", "0"],
["1", "1", "1"]
]
}Output: area 4
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.