⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 33s17 days 22 hours 19 minutes 33 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 19m 33s17 days 22 hours 19 minutes 33 seconds.

Sign in to watch this lesson
Advanced - Dynamic Programming · 4:34
To find the largest all-zero rectangle in a grid, we fix the rectangle's bottom row and sweep it downward, keeping one number per column: the row of the nearest blocked cell above. That turns every row into a histogram, where the best rectangle is a bar's height times the gap between the nearest shorter bars on each side, and a monotonic stack finds those walls in one linear pass, for O(n·m) time and O(m) memory.