mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
11 lines
182 B
Go
11 lines
182 B
Go
package leetcode
|
|
|
|
func runningSum(nums []int) []int {
|
|
dp := make([]int, len(nums)+1)
|
|
dp[0] = 0
|
|
for i := 1; i <= len(nums); i++ {
|
|
dp[i] = dp[i-1] + nums[i-1]
|
|
}
|
|
return dp[1:]
|
|
}
|