Problem 2: Matrix Diagonal Sum (easy)
Given a square matrix (2D array), calculate the sum of its two diagonals.
The two diagonals in consideration are the primary diagonal that spans from the top-left to the bottom-right and the secondary diagonal that spans from top-right to bottom-left. If a number is part of both diagonals (which occurs only for odd-sized matrices), it should be counted only once in the sum.
[[1,2,3], [4,5,6], [7,8,9]]
[[1,0], [0,1]]
[[5]]
Constraints:
n == mat.length == mat[i].length1 <= n <= 1001 <= mat[i][j] <= 100