Advertisement
kucheasysa

Algoverse_adesh_22

Jun 20th, 2024
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1.  
  2. class Solution:
  3.     def diagonalSum(self, mat: List[List[int]]) -> int:
  4.         n = len(mat)
  5.         m = 0
  6.         for i in range(n) :
  7.             m += mat[i][i] + mat[i][n - i - 1]
  8.         if n % 2 :
  9.             w = n // 2
  10.             m -= mat[w][w]
  11.         return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement