dsa · hard
Maximal Rectangle
matrix is an m × n grid of "0" and "1" characters. Return the area of the largest rectangle that contains only "1" and whose sides are parallel to the axes.
Arguments
matrix— m×n grid of "0"/"1" characters; the rectangle must cover only "1"s
Example
`` 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 ``
The 2 × 3 block of ones in rows 1–2, columns 2–4 has area 6. That is the maximum.
A single "0" → 0. A single "1" → 1.
Constraints
1 <= m, n <= 200 matrix[i][j] is "0" or "1" Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Expected: 6