C++ | O(n^4) TIme |  O(n) Space
\nclass Solution {\npublic:\n    int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {\n        \n        int n = matrix.size(), m = matrix[0].si
```\nclass Solution {\npublic:\n    int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {\n        \n        int n = matrix.size(), m = matrix[0].size(), ans = 0;\n        \n        for(int i=0; i<n; i++){\n            for(int j=0; j<m; j++){\n                \n                vector<int>tmp(m, 0);\n                for(int k=i; k<n; k++){\n                    int s = 0;\n                    for(int l=j; l<m; l++){\n                        s += matrix[k][l];\n                        tmp[l] += s;\n                        if(tmp[l]==target)\n                            ans++;\n                    }\n                }\n                \n            }\n        }\n        \n        return ans;\n    }\n};\n```\n\nComplextiy:\n\u2981\tTime: O((m*n)^2)\n\u2981\tSpace: O(n)\n
['C', 'Matrix', 'Prefix Sum', 'C++']