Elegant python dp solution beats 100%
```\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        rowLen = len(matrix)\n        colLen = len(matrix[0])\n        memo =
```\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        rowLen = len(matrix)\n        colLen = len(matrix[0])\n        memo = [[0]*colLen for _ in range(rowLen)]\n        count = 0\n        \n        for row in range(rowLen):\n            for col in range(colLen):\n                if matrix[row][col] == 1:\n                    memo[row][col] = 1 + min(memo[row][col - 1], memo[row - 1][col], memo[row - 1][col - 1])\n                    count += memo[row][col]\n        \n        return count
['Dynamic Programming', 'Python', 'Python3']