30:00
Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.
1≤arr.length≤3001 \leq \text{arr.length} \leq 3001≤arr.length≤300
1≤arr[0].length≤3001 \leq \text{arr}[0]\text{.length} \leq 3001≤arr[0].length≤300
0≤arr[i][j]≤10 \leq \text{arr}[i][j] \leq 10≤arr[i][j]≤1
Run code to see results.
dp[i][j] = side of the largest all-ones square whose bottom-right corner is cell (i, j). It also equals how many squares end there.
■ current
■ up
■ left
■ diagonal
■ squares ending here
0
1
total = 0
Given a grid of 0s and 1s, count every square block (of any size) made only of 1s.