HTMLify

LeetCode - Matrix Diagonal Sum - Python
Views: 135 | Author: abh
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

Comments