I was using a website called LeetCode trying to write a piece of code for this:
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].
I eventually wrote this code that someone told me about:
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
output = []
sum = 0
for i in nums:
sum += i
output.append(sum)
return output
One thing I am confused about is this:
List[]
What exactly is this?