Skip to content

Commit 2d75909

Browse files
authored
Create running-sum-of-1d-array.py
1 parent b94cc2c commit 2d75909

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Python/running-sum-of-1d-array.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def runningSum(self, nums):
6+
"""
7+
:type nums: List[int]
8+
:rtype: List[int]
9+
"""
10+
for i in xrange(len(nums)-1):
11+
nums[i+1] += nums[i]
12+
return nums

0 commit comments

Comments
 (0)