✅ C++ , Variation of Subarray sum equals k
\nclass Solution {\npublic:\n    int numSubmatrixSumTarget(vector<vector<int>>& mat, int target) {\n        int n=mat.size();\n        int m=mat[0].size();\n   
```\nclass Solution {\npublic:\n    int numSubmatrixSumTarget(vector<vector<int>>& mat, int target) {\n        int n=mat.size();\n        int m=mat[0].size();\n        \n        // STEP 01 : prefix sum\n        for(int i=0;i<n;i++){\n            for(int j=1;j<m;j++){\n                mat[i][j] += mat[i][j-1];\n            }\n        }\n        \n        int res=0;\n        \n        // STEP 02 : for every pair of column perform operation - subarray sum technique with \n        //           with sliding window to get every apir of column\n        for(int c1=0;c1<m;c1++){\n            for(int c2=c1;c2<m;c2++){\n                \n                // since we handled every column pair now work on operation on every rows\n                // subarray sum equals k technique\n                int sum=0;\n                unordered_map<int,int> mp;\n                mp[0]=1;\n                \n                for(int row=0;row<n;row++){\n                    \n                    sum+=mat[row][c2];\n                    \n                    // remove extra left part(search space) if there \n                    if(c1>0) sum-=mat[row][c1-1];\n                    \n                    // exact same as subarray sum equals k\n                    int srch = sum-target;\n                    \n                    if(mp.find(srch)!=mp.end()) res += mp[srch];\n                    \n                    mp[sum]++;\n                }\n            }\n        }\n        return res;\n    }\n};\n```
['Array', 'Hash Table', 'C', 'Sliding Window', 'Prefix Sum']