Running Sum of 1d Array - LeetCode

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.

write

write

"""
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.

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]
"""

List = [1,2,3,4]
new_List = []
total = 0
i = 0

new_List.append(List[0])

while i < len(List) - 1:
    new_List.append(new_List[i] + List[i + 1])

    i += 1

print(new_List)

in leetcode

in leetcode