1480. Running Sum of 1d Array
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 87% Topics: Array, Prefix Sum
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def runningSum(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
for i in xrange(len(nums)-1):
nums[i+1] += nums[i]
return nums
Solution from kamyu104/LeetCode-Solutions · MIT