Problem 1504 · Medium

Count Submatrices With All Ones

Count all-one rectangles in a grid by building column heights row by row and counting runs in a histogram-style sweep. The visual shades each counted rectangle.

Open the interactive visualisation