Simple Solution || Beats 100% in Space Complexity
\n# Code\n\nclass Solution {\n    public int diagonalSum(int[][] mat) {\n        int sum=0;\n        for(int i=0;i<mat.length;i++) {\n            for(int j=0;j<
\n# Code\n```\nclass Solution {\n    public int diagonalSum(int[][] mat) {\n        int sum=0;\n        for(int i=0;i<mat.length;i++) {\n            for(int j=0;j<mat[0].length;j++) {\n                if(i == j || (i+j) == mat.length-1) {\n                    sum+=mat[i][j];\n                }\n            }\n        }\n        System.gc();\n        return sum;\n    }\n}\n```
['Java']