Running Total
You are given a list of integers nums. Return a list of the same length in which the value at index i is the total of all numbers up to and including nums[i].
Examples
nums = [1, 2, 3, 4] → [1, 3, 6, 10]
nums = [5, -2, 0, 7] → [5, 3, 3, 10]
nums = [1, 1, 1, 1, 1] → [1, 2, 3, 4, 5]In the first example the totals are 1, 1 + 2, 1 + 2 + 3 and 1 + 2 + 3 + 4.
Constraints
- Between 0 and 10,000 numbers, each between -100,000 and 100,000.
- Aim for O(n): one addition per number.
Console
›Run to see what your code prints
Run checks the 3 visible cases here, in your browser. Submit runs all 7 on the judge, 4 of them hidden, and measures how your solution scales.
Expected is the reference solution's answer, from the judge. An input that breaks the statement's other rules may get any answer.