C++ || RECURSION + MEMOIZATION || CLEAN CODE
```\nclass Solution {\npublic:\n    int dp[301][301];\n    int solve(vector>& matrix, int i, int j){\n        if(i >= matrix.size() || j >= matrix[0].size() || 
```\nclass Solution {\npublic:\n    int dp[301][301];\n    int solve(vector<vector<int>>& matrix, int i, int j){\n        if(i >= matrix.size() || j >= matrix[0].size() || matrix[i][j] == 0) return 0;\n        if(dp[i][j] != -1) return dp[i][j];\n        int cur_ans;\ncur_ans = 1 + min(solve(matrix, i + 1, j), min(solve(matrix, i, j + 1), solve(matrix, i + 1, j + 1)));\n        return dp[i][j] = cur_ans;\n        \n    }\n    int countSquares(vector<vector<int>>& matrix) {\n          int ans = 0;\n          int row = matrix.size();\n          int col = matrix[0].size();\n          memset(dp, -1, sizeof(dp));\n          for(int i = 0; i < row; i++){\n              for(int j = 0; j < col; j++){\n                   if(matrix[i][j] == 1){\n                       ans += solve(matrix, i, j);\n                   }\n              }\n          }\n        return ans;\n    }\n};
['Memoization', 'C']