题目
Given a m * n
matrix of ones and zeros, return how many square submatrices have all ones.
Example 1:
1 | Input: matrix = |
Example 2:
1 | Input: matrix = |
Constraints:
1 <= arr.length <= 300
1 <= arr[0].length <= 300
0 <= arr[i][j] <= 1
思路
DP.
1 | dp[i][j] = edge of largest square with bottom right corner at (i, j) |
1 | Time complexity: O(n*m) |
代码
1 | class Solution(object): |