AlgoMaster Logo

Count Square Submatrices with All Ones

matrix=[[0,1,1,1],[1,1,1,1],[0,1,1,1]]
0 / 16
3x4 count = 0011111110111each 1 counts the squares ending at it; the answer is the sum
algomaster.io
Step:Count every all-1s square. Each 1 answers: how many squares END at me? Sum the answers