Running Sum of an Array
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
1 <= len(nums) <= 100-100 <= nums[i] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Arrays problems
- Second AppearanceBeginner
- Shift Right and FillBeginner
- Shuffle the ArrayBeginner
- Sort by ParityBeginner
- Trend SignsBeginner
- Alternate the SignsEasy
- Drop the Lowest ScoresEasy
- Fair CutsEasy