HTMLify
LeetCode - Matrix Diagonal Sum - Python
Views: 521 | Author: abh
1 2 3 4 5 6 7 8 9 10 | class Solution: def diagonalSum(self, mat: List[List[int]]) -> int: i = 0 s = 0 if len(mat)%2: s -= mat[len(mat)//2][len(mat)//2] for row in mat: s += row[i] + row[len(mat)-i-1] i += 1 return s |