Problem
Build a running sum: the value at position i is the sum of all numbers from position 0 through i.
Implement running_sum(numbers).
Input
numbers: The list of integers.
Output
Return the list of running totals.
Constraints
0 ≤ length ≤ 100,000; totals fit in a 64-bit integer
Examples
Example 1
Input:
numbers = [1, 2, 3, 4]
Expected output:
expected = [1, 3, 6, 10]
Input:
std::vector<long long> numbers = {1, 2, 3, 4};
Expected output:
std::vector<long long> expected = {1, 3, 6, 10};
Input:
long[] numbers = new long[] {1, 2, 3, 4};
Expected output:
long[] expected = new long[] {1, 3, 6, 10};
Explanation
Totals so far: 1, 1+2=3, 3+3=6, 6+4=10.
Example 2
Input:
numbers = [5, -5, 5]
Expected output:
expected = [5, 0, 5]
Input:
std::vector<long long> numbers = {5, -5, 5};
Expected output:
std::vector<long long> expected = {5, 0, 5};
Input:
long[] numbers = new long[] {5, -5, 5};
Expected output:
long[] expected = new long[] {5, 0, 5};
Explanation
Totals: 5, 0, 5.
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.