iq.lab
Python sleeps until you run code
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
Inputnums = [1, 2, 3, 4]Output[1, 3, 6, 10]

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

Example 2
Inputnums = [3, -1, 2]Output[3, 2, 4]
Constraints
  • 0 ≤ len(nums) ≤ 10^5

  • -10^6 ≤ nums[i] ≤ 10^6

⌘+Enter runs 0:00Python sleeps until you run code
Run examples checks the examples. Submit runs every test, including edge cases and a large input.