Simple java code 79 ms beats 98.84 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] nums, int t) {\n        int row=nums.length;\n        int col=num
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/868fb304-6d7f-4d00-86fe-0fc186fe1cc2_1706405946.013867.png)\n# Code\n```\nclass Solution {\n    public int numSubmatrixSumTarget(int[][] nums, int t) {\n        int row=nums.length;\n        int col=nums[0].length;\n        int count=0;\n        for(int i=0;i<row;i++) {\n            int arr[]=new int[col];\n            for(int j=i;j<row;j++) {\n                for(int k=0;k<col;k++) {\n                    arr[k]+=nums[j][k];\n                }\n                for(int l=0;l<col;l++) {\n                    int sum=0;\n                    for(int r=l;r<col;r++) {\n                        sum+=arr[r];\n                        if(sum==t) {\n                            count++;\n                        }\n                    }\n                }\n            }\n        }\n        return count;\n    }\n}\n```
['Array', 'Matrix', 'Prefix Sum', 'Java']