Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def countSquares(self, matrix: List[List[int]]) -> int:
- n = len(matrix)
- m = len(matrix[0])
- for i in range(1, n):
- for j in range(1, m):
- if matrix[i][j] == 1:
- matrix[i][j] = min(matrix[i-1][j], matrix[i][j-1], matrix[i-1][j-1]) + matrix[i][j]
- return sum(map(sum, matrix))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement