C++ Easy Solution | O(n.m) Time
\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n       int count = 0; \n       int n = matrix.size(); // row\n       int m = m
```\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n       int count = 0; \n       int n = matrix.size(); // row\n       int m = matrix[0].size(); // column\n        \n       vector<vector<int>> d((n), vector<int> (m));\n       \n       for(int i=0; i < m; i++){\n           d[0][i] = matrix[0][i];\n           cout<<d[0][i]<< " ";\n           count = count +  d[0][i];\n       } \n       \n       for(int i=1; i<n; i++){\n           d[i][0] = matrix[i][0];\n           count = count +  d[i][0];\n       } \n        \n       for(int i=1; i < n; i++){\n           for(int j=1; j < m; j++){\n               if(matrix[i][j] == 1){\n                   d[i][j] = 1 + min(d[i-1][j], min(d[i-1][j-1], d[i][j-1]));\n                   count = count + d[i][j];\n               }\n           }\n       }\n        return count;\n    }\n};\n```
[]