C++ , easy , short and fast DP
```\nclass Solution {\npublic:\n    int countSquares(vector>& matrix) {\n          \n        if (matrix.empty())   return 0;  \n        int m = matrix.size();\n
```\nclass Solution {\npublic:\n    int countSquares(vector<vector<int>>& matrix) {\n          \n        if (matrix.empty())   return 0;  \n        int m = matrix.size();\n        int n = matrix[0].size();\n        int size = 0;       \n        \n        vector<vector<int>> dp(m, vector<int>(n, 0));\n        \n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                \n                // initilization of dp[0] and also all 0 are covered\n                if (!i || !j || matrix[i][j] == 0) {\n                    dp[i][j] = matrix[i][j] ;\n                } \n                \n                // since all 0 are in the if loop\n                // if the min value in all the squares top left right is 1 then add 1 and make it size 2\n                else {\n                    dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;\n                }\n                size = dp[i][j] + size;\n            }\n        }\n        return size;\n    }\n};
['Dynamic Programming', 'C']