[C++] Short & Easy Solution
\n    int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {\n        int rows = matrix.size(), cols = matrix[0].size();\n        int count = 0;\n
```\n    int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {\n        int rows = matrix.size(), cols = matrix[0].size();\n        int count = 0;\n        for(int L=0; L<cols; L++) {\n            vector<int> running_rows(rows,0); //intialize the running row\n            for(int R=L; R<cols; R++) { //calculate running rows sum\n                for(int i=0; i<rows; i++) running_rows[i] += matrix[i][R]; \n                int sum = 0;\n                unordered_map<int, int> visited;\n                for(int i=0; i<rows; i++) { //check for subarrays in every running row\n                    visited[sum]++;\n                    sum = sum + running_rows[i];\n                    if(visited[sum - target]) \n                        count += visited[sum - target];\n                }\n            }\n        }\n        return count;\n    }\n```\n\nRuntime - O(cols^2 rows) i.e cubic runtime\nSpace - O(rows)\n\nTo understand what are running rows, watch : https://www.youtube.com/watch?v=-FgseNO-6Gk\nTo understand how I\'m checking for subarrays in every single running row, try : https://leetcode.com/problems/subarray-sum-equals-k/ or check out this video on youtube to understand the solution https://www.youtube.com/watch?v=AmlVSNBHzJg
['Array', 'C', 'C++']