Simple Java Solution, No hash map
\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] matrix, int target) {\n        int ans = 0;\n\n        for(int i = 0; i<matrix[0].length;i++){/
```\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] matrix, int target) {\n        int ans = 0;\n\n        for(int i = 0; i<matrix[0].length;i++){//left col\n            int[] sum = new int[matrix.length];\n            for(int m = i; m<matrix[0].length;m++){//right col\n                for(int j = 0; j<matrix.length;j++){\n                    sum[j]+=matrix[j][m];//add left to right\n                    if(sum[j]==target)ans++;            \n                }\n                for(int j = 0; j<matrix.length;j++){//up row\n                    int summe=0;    \n                    for(int n = j; n<matrix.length;n++){//down row\n                        summe+=sum[n];add up to down\n                        if(n!=j&&summe==target)ans++;\n                    }\n                }\n            }\n        }\n        \n        return ans;\n\n    }\n}\n```
['Java']