Count Square Submatrices

MATRIX

### Problem

Given a 2D binary matrix `matrix`

, return the total number of square submatrices that have all ones. This includes squares of any size that are composed entirely of '1's, located anywhere within the matrix.

### Examples

`countSquares([ [0,1,1,1], [0,1,1,0], [0,1,1,0] ]) // returns 9 /* Why? There's 7 squares of size 1 And there's 2 squares of size 2 */`

Loading...

1

0

1

1

1

1

0

1

0

1

1

1