JAVA Solution Explained in HINDI
https://youtu.be/rCTugCzGFV4\n\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvot
https://youtu.be/rCTugCzGFV4\n\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\nSubscribe link:- https://youtube.com/@quantumCode7?si=NzjWYmiCbqfFBUJE\n\nSubscribe Goal:- 100\nCurrent Subscriber:- 82\n\n# Code\n```\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] matrix, int target) {\n        \n        int m = matrix.length;\n        int n = matrix[0].length;\n\n        int sumRow[] = new int[n];\n        int ans = 0;\n\n        for(int i = 0; i < m; i++) { // i is the starting row\n            Arrays.fill(sumRow, 0);\n            for(int j = i; j < m; j++) { // j is the ending row\n                for(int k = 0; k < n; k++) { // k is the column\n                    sumRow[k] += matrix[j][k];\n                }\n                ans += subarraySum(sumRow, target);\n            }\n        }\n        return ans;\n    }\n\n    public int subarraySum(int[] nums, int k) {\n        \n        int sum = 0;\n        int ans = 0;\n\n        Map<Integer, Integer> prefixSum = new HashMap<>();\n        prefixSum.put(0, 1);\n\n        for(int i = 0; i < nums.length; i++) {\n            sum += nums[i];\n            if(prefixSum.containsKey(sum - k)) {\n                ans += prefixSum.get(sum - k);\n            }\n            prefixSum.put(sum, prefixSum.getOrDefault(sum, 0) + 1);\n        }\n        return ans;\n    }\n}\n```
['Java']