[Kotlin] Single loop, straightforward
\n\nclass Solution {\n    fun diagonalSum(mat: Array<IntArray>): Int {\n        var sum = 0\n        for (i in mat.indices) {\n            sum += (mat[i][i] + m
\n```\nclass Solution {\n    fun diagonalSum(mat: Array<IntArray>): Int {\n        var sum = 0\n        for (i in mat.indices) {\n            sum += (mat[i][i] + mat[mat.lastIndex-i][i])\n        }\n\n        if (mat.size % 2 != 0) {\n            sum -= mat[mat.lastIndex / 2][mat.lastIndex / 2]\n        }\n\n        return sum\n    }\n}\n```
['Kotlin']