Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Andrew Sologor
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