Count Square Submatrices with All Ones

Medium · Dynamic Programming · about 15 minutes

Asked at Google, Amazon, Microsoft, Meta.

Given an m × n matrix of 0s and 1s, return how many square submatrices consist entirely of 1s.

Related guides