21. Max Rectangle
β GFG solution to the Max Rectangle problem: find maximum area rectangle in binary matrix using largest rectangle in histogram approach with stack optimization. π
π§© Problem Description
π Examples
Example 1
Input: mat[][] = [[0, 1, 1, 0],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 0, 0]]
Output: 8
Explanation: The largest rectangle with only 1's is from (1, 0) to (2, 3) which is
[1, 1, 1, 1]
[1, 1, 1, 1]
and area is 4 * 2 = 8.Example 2
π Constraints
β
My Approach
Histogram + Stack Approach
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated