Easy to understand solution
It is actually a combination of 2 problems but slightly twisted:\nproblem 1: Find number of sub arrays with target sum\nproblem 2: Find largest sub matrix with 
It is actually a combination of 2 problems but slightly twisted:\nproblem 1: Find number of sub arrays with target sum\nproblem 2: Find largest sub matrix with target sum\n\nFor problem 1: I followed the same hashmap approach as listed in this leetcode problem: https://leetcode.com/problems/subarray-sum-equals-k/solution/\nFor problem 2: here is an excellent video which you will understand in 1 go. https://www.youtube.com/watch?time_continue=173&v=yCQN096CwWM&feature=emb_logo\n\nNow just twist problem 2 and instead of saying find Maximum Sum Rectangular Submatrix, find all subarrays with sum equal to k.\n\nIf you understand problem 2 deeply then you will understand that the problem is actually very simple and not complex at all.\n\n***Java***\n```\n    public int numSubmatrixSumTarget(int[][] matrix, int target) {\n        if(matrix == null) {\n            return 0;\n        }\n        int rowLen = matrix.length;\n        int colLen = matrix[0].length;\n        int answer = 0;\n\n        for(int left = 0;left < colLen;left++) {\n            int[] tempArr = new int[rowLen];\n            for(int right = left; right < colLen; right++) {\n                for(int row = 0; row < rowLen; row++) {\n                    tempArr[row] = tempArr[row] + matrix[row][right];\n                }\n                answer = answer + subarraySum(tempArr, target);\n            }\n        }\n        return answer;\n    }\n\n    public int subarraySum(int[] arr, int target) {\n        Map<Integer, Integer> map = new HashMap<>();\n        map.put(0, 1);\n        int ans = 0;\n        int sumSoFar = 0;\n        for(int i=0;i<arr.length ;i++) {\n            sumSoFar = sumSoFar + arr[i];\n            int requiredSum = sumSoFar - target;\n            if(map.containsKey(requiredSum)) {\n                ans = ans + map.get(requiredSum);\n            }\n            map.put(sumSoFar, map.get(sumSoFar) != null ? map.get(sumSoFar) + 1 : 1);\n        }\n        return ans;\n    }\n\t
[]