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<=1 <= matrix.length <=900<= 900
  • 1<=1 <= matrix[i].length <=900<= 900
  • matrix[i][j] is either 00 or 11

Examples

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