0
0
Read Time:24 Second
Return the running sum of nums
.
Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
class Solution(object):
def runningSum(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
output=[]
for i in range(1,len(nums)+1):
sum=0
for j in range(0,i):
sum=sum+nums[j]
output.append(sum)
return output