✔️ C++ || Easy || Prefix-Sum || Sliding Window
\nclass Solution\n{\n    public:\n        int numSubmatrixSumTarget(vector<vector < int>> &matrix, int target)\n        {\n            int m = matrix.size();\n 
````\nclass Solution\n{\n    public:\n        int numSubmatrixSumTarget(vector<vector < int>> &matrix, int target)\n        {\n            int m = matrix.size();\n            int n = matrix[0].size();\n            \n            for (int i = 0; i < m; i++)\n            {\n                for (int j = 1; j < n; j++)\n                {\n                    matrix[i][j] += matrix[i][j - 1];\n                }\n            }\n            \n            int count = 0;\n            \n            for (int i = 0; i < n; i++)\n            {\n                for (int j = i; j < n; j++)\n                {\n                    map<int, int> mp;\n                    mp[0] = 1;\n                    int sum = 0;\n                    for (int k = 0; k < m; k++)\n                    {\n                        sum += matrix[k][j] - (i > 0 ? matrix[k][i - 1] : 0);\n                        count += mp[sum - target];\n                        mp[sum]++;\n                    }\n                }\n            }\n            \n            return count;\n        }\n};\n````
['C', 'Sliding Window', 'Prefix Sum']