FunctionRacerProblemsRace

Running Sum of an Array

BeginnerArraysPython, JavaScript, TypeScript, Java, C++

Return a new list where the item at index i is the sum of nums[0] through nums[i].

Do not change nums.

Example 1

nums [1,2,3,4]
returns [1,3,6,10]

1, 1+2, 1+2+3, 1+2+3+4.

Example 2

nums [3,-1,2]
returns [3,2,4]

3, then 3-1 = 2, then 2+2 = 4.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems