You are viewing a single comment's thread. Return to all comments →
Same solution in golang
func arrayManipulation(n int32, queries [][]int32) int64 { arr := make([]int64, n+1) for _, element := range queries { a := int(element[0]) b := element[1] k := int64(element[2]) arr[a] += k if (b + 1) <= n { arr[b+1] -= k } } var x, max int64 = 0, 0 for i := 1; i <= int(n); i++ { x += arr[i] if max < x { max = x } } return max }
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
Same solution in golang