1572. Matrix Diagonal Sum
Last updated
Was this helpful?
Last updated
Was this helpful?
https://leetcode.com/problems/matrix-diagonal-sum
Given a square matrix mat
, return the sum of the matrix diagonals.
Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.
Example 1:
Example 2:
Example 3:
Constraints:
n == mat.length == mat[i].length
1 <= n <= 100
1 <= mat[i][j] <= 100