hardDynamic Programming 2DPure DSA~45 min
Largest All-Healthy Block
A fleet-health matrix marks each node-by-time cell '1' (healthy) or '0' (degraded). To size the largest clean maintenance window across contiguous nodes, find the biggest all-'1' rectangle.
Problem
Given a binary matrix of '0' and '1' characters, find the area of the largest rectangle containing only '1's.
Input
An m×n matrix of characters '0'/'1' (1 ≤ m, n ≤ 200).
Output
An integer: the maximum all-ones rectangle area.
Constraints
- 1 ≤ m, n ≤ 200
- Cells are '0' or '1'
- Rectangle sides are axis-aligned
Examples
Example 1
Input
matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
Output
6
The 2×3 block in the lower middle has area 6.
Example 2
Input
matrix = [["0"]]
Output
0
No ones, so the largest rectangle is empty.