c++ memoization
\n\n# Code\n\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n            int res=0;\n            for(int i=0;i<matrix.size();i+
\n\n# Code\n```\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n            int res=0;\n            for(int i=0;i<matrix.size();i++){\n                for(int j=0;j<matrix[0].size();j++){\n                    if(i>0 && j>0 && matrix[i][j]!=0){\n                        matrix[i][j]=min(matrix[i-1][j-1],min(matrix[i-1][j],matrix[i][j-1]))+1;\n                    }\n                    res+=matrix[i][j];\n                }\n            }\n        return res;\n    }\n};\n```
['Memoization', 'C++']