Superb Logic Python3 ---->DP
Dynamic Programming\n\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        row=len(matrix)\n        col=len(matrix[0])\n      
# Dynamic Programming\n```\nclass Solution:\n    def countSquares(self, matrix: List[List[int]]) -> int:\n        row=len(matrix)\n        col=len(matrix[0])\n        dp=[[0]*col for i in range(row)]\n        for i in range(row):\n            for j in range(col):\n                if (i==0 or j==0) and matrix[i][j]==1:\n                    dp[i][j]=1\n        for i in range(1,row):\n            for j in range(1,col):\n                if matrix[i][j]==1:\n                    dp[i][j]=1+min(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])\n        ans=0\n        for rows in dp:\n            ans+=sum(rows)\n        return ans\n```    \n# please upvote me it would encourage me alot\n\n\t
['Dynamic Programming', 'Python', 'Python3']