1480. Running Sum of 1d Array
Given an array nums
. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i])
.
Return the running sum of nums
.
求数组的前缀和
class Solution(object): def runningSum(self, nums): """ :type nums: List[int] :rtype: List[int] """ for i in range(1, len(nums), 1): nums[i] += nums[i - 1] return nums