You are viewing a single comment's thread. Return to all comments →
Solution in Golang
var sumLeft, sumRight int32 for i, j := 0, 1; i < len(arr) && j <= len(arr); i, j = i+1, j+1{ sumLeft = sumLeft + arr[i][i] sumRight = sumRight + arr[i][len(arr)-j] } return int32(math.Abs(float64(sumLeft) - float64(sumRight))) }
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Solution in Golang
var sumLeft, sumRight int32 for i, j := 0, 1; i < len(arr) && j <= len(arr); i, j = i+1, j+1{ sumLeft = sumLeft + arr[i][i] sumRight = sumRight + arr[i][len(arr)-j] } return int32(math.Abs(float64(sumLeft) - float64(sumRight))) }