JAVA||EASY||EXPLAINED||VERY SIMPLE O(M*N*M)`
\nsee u can first find the row prefix sum\nthen take two pointer one on 0 and other on say x  then traverse row and as u did in to find the subarray sum equal t
```\nsee u can first find the row prefix sum\nthen take two pointer one on 0 and other on say x  then traverse row and as u did in to find the subarray sum equal to k just do that that is sum-target+target=sum if u can store sum at some point u will realise that u are finding target because sum-(sum-target)=target if u have the count of sum-target u hv to just add it up\n```\n\n\n```\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] matrix, int target)\n    {\n        int n=matrix.length;\n        int m=matrix[0].length;\n        long dp[][]=new long[n][m];\n        for(int i=0;i<n;i++)\n        {\n            dp[i][0]=matrix[i][0];\n        }\n        for(int i=0;i<n;i++)\n        {\n            for(int j=1;j<m;j++)\n            {\n                dp[i][j]=dp[i][j-1]+matrix[i][j];\n            }\n        }\n        int count=0;\n        for(int start=0;start<m;start++)\n        {\n            for(int end=start;end<m;end++)\n            {\n                HashMap<Long,Integer> map=new  HashMap<Long,Integer>();\n                long sum=0;\n                for(int i=0;i<n;i++)\n                {\n                    map.put(sum,map.getOrDefault(sum,0)+1);\n                    long pre=start!=0?dp[i][start-1]:0;\n                    sum+=dp[i][end]-pre;\n                    if(map.containsKey(sum-target))\n                    {\n                        count+=map.get(sum-target);\n                    }\n                }\n            }\n        }\n        return count;\n        \n    }\n}\n```\n\n# ***PLS UPVOTE IF U LIKE THE SOLUTION* **
['Dynamic Programming', 'Prefix Sum', 'Java']