Easy
,Array
,Matrix
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
n
<= 100mat[i][j]
<= 100Yen-Chi ChenMon, May 8, 2023
Ron ChenMon, May 8, 2023
MarsgoatMon, May 8, 2023
SheepMon, May 8, 2023