1. How I sloved
I made a variable named ‘sum’, add it with each element of ‘nums’ and returned the sum of each element and ‘sum’.
2. Code
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
sum = 0
output_list = []
for num in nums:
sum += int(num)
output_list.append(sum)
return output_list
3. Result
Runtime : 40 ms(74.06%), Memory usage : 13.9 MB(84.57%)
(Runtime can be different by a system even if it is a same code.)