Java Beginner Approach (Easy)
If the number in the matrix has the index of column and row equal or index of row + column equal to length of matrix (with index 0 (n-1)), then it is the number
If the number in the matrix has the **index of column and row equal** or **index of row + column equal to length of matrix** (with index 0 **(n-1)**), then it is the number in the diagonal line.\n\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[i].length; j++ ) {\n                if(i==j || i+j==mat.length-1)\n                    sum+=mat[i][j];\n            }\n        }\n        return sum;\n    }\n}\n```
['Java']