Back to course home
0% completed
Vote For New Content
Efficient two pointer solution
Andrew Sologor
Apr 10, 2025
func diagonalSum(mat [][]int) int { totalSum := 0 i := 0 j := len(mat) - 1 for j >= 0 { totalSum += mat[i][i] if i != j { totalSum += mat[i][j] } i++ j-- } return totalSum }
0
0
Comments
Comments
On this page