easyLoops and basicsPrefix sums target 15 min
Running sum
Given a list of numbers nums, return a new list of the same length where the item at position i is the sum of nums[0] through nums[i].
Example 1
Input
nums = [1, 2, 3, 4]Output[1, 3, 6, 10]1, then 1 + 2, then 1 + 2 + 3, then 1 + 2 + 3 + 4.
Example 2
Input
nums = [3, -1, 2]Output[3, 2, 4]Constraints
0 ≤ len(nums) ≤ 10^5
-10^6 ≤ nums[i] ≤ 10^6
Run examples checks the examples. Submit runs every test, including edge cases and a large input.