[Java/Python 3] Simple code w/ brief explanation and analysis.
If the length of the matrix is odd, then the center cell will be overlapped on the two diagonals, we should deduct it from the result.\n2. The cells on secondar
1. If the length of the matrix is odd, then the center cell will be overlapped on the two diagonals, we should deduct it from the result.\n2. The cells on secondary (or skew) diagonal meet the rule: `i + j = n - 1`, where `i`, `j` are the coordinates of the cell and `n` is the length of the matrix.\n```java\n    public int diagonalSum(int[][] mat) {\n        int n = mat.length, sum =  n % 2 == 1 ? -mat[n / 2][n / 2] : 0;\n        for (int i = 0; i < n; ++i) {\n            sum += mat[i][i] + mat[i][n - 1 - i]; \n        }\n        return sum;        \n    }\n```\n```python\n    def diagonalSum(self, mat: List[List[int]]) -> int:\n        n = len(mat)\n        return sum(mat[i][i] + mat[i][n - i - 1] for i in range(n)) - (mat[n // 2][n // 2] if n % 2 == 1 else 0)\n```\nOr\n```python\n    def diagonalSum(self, mat: List[List[int]]) -> int:\n        n = len(mat)\n        return sum(row[r] + row[n - 1 - r] for r, row in enumerate(mat)) - (0, mat[n // 2][n // 2])[n % 2]\n```\nOr **@votrubac**\'s method:\n \n```python\n    def diagonalSum(self, mat: List[List[int]]) -> int:\n        n = len(mat)\n        return sum(row[c] for r, row in enumerate(mat) for c in {r, n - 1 - r})\n```\n**Analysis:**\n\nTime: O(n), space: O(1), where n = mat.length.
[]