...

/

Count Square Submatrices

Count Square Submatrices

Given a matrix containing only ones and zeros, return the count of square submatrices with all ones.

Statement

Given an N ∗ M matrix containing only ones and zeros, count the total number of square submatrices that contain only 1’s.

Example

Consider the input matrix given below. We have a total of 77 square submatrices with all ones, including 66 square matrices of order 1 x 1 and 11 square matrix of order 2 x 2.

Sample input

[
  [1,0,1],
  [1,1,0],
 
...