# Count Square Submatrices

Let's solve the Count Square Submatrices problem using Dynamic Programming.

## Statement

Given a matrix containing only ones and zeros, count the total number of square submatrices that contain only ones.

If the matrix is empty, then return 0.

**Constraints**:

- $1 <=$
`matrix.length`

$<= 900$ - $1 <=$
`matrix[i].length`

$<= 900$ `matrix[i][j]`

is either $0$ or $1$

## Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.