Leetcode Note: Go - Running Sum of 1d Array
Running Sum of 1d Array - LeetCode
https://leetcode.com/problems/running-sum-of-1d-array/
- Go 言語で取り組んだメモ
回答
[Go] O(N) memory O(1)space - Running Sum of 1d Array - LeetCode
https://leetcode.com/problems/running-sum-of-1d-array/solutions/1300739/go-o-n-memory-o-1-space/
func runningSum(nums []int) []int {
for i:= 1; i< len(nums); i++ {
nums[i] += nums[i-1]
}
return nums
}