C++ easy DP solution
```\nclass Solution {\npublic:\n    int countSquares(vector>& matrix) {\n        //dp[i][j] means the biggest square with A[i][j] as bottom-right corner.\n     
```\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n        //dp[i][j] means the biggest square with A[i][j] as bottom-right corner.\n            int res=0;\n            for (int i=0; i<matrix.size(); i++)\n            {\n                    for (int j=0; j<matrix[0].size(); j++)\n                    {\n                         if (matrix[i][j]&&i&&j)  matrix[i][j]+=min({matrix[i-1][j], matrix[i-1][j-1], matrix[i][j-1]});\n                         res+=matrix[i][j];\n                    }\n            }\n            return res;\n    }\n};
[]