Approach hintTry it first, then revealHide
Treat each row as the base of a histogram whose bar heights count the consecutive 1s ending at that row, and run the largest-rectangle-in-histogram stack routine on every row. O(rows * cols).
Treat each row as the base of a histogram whose bar heights count the consecutive 1s ending at that row, and run the largest-rectangle-in-histogram stack routine on every row. O(rows * cols).