Maximal Rectangle
Find the largest rectangle of 1s in a binary matrix. Turn each row into a histogram of consecutive 1s above it, then solve Largest Rectangle in Histogram with a monotonic stack.
Spotted a mistake in this lesson?Report an issue →
Find the largest rectangle of 1s in a binary matrix. Turn each row into a histogram of consecutive 1s above it, then solve Largest Rectangle in Histogram with a monotonic stack.