Running Sum of an Array (Set 4)

Easy

Given an array of integers nums, return the running sum: index i of the result holds the sum of nums[0] through nums[i].

Running Sum of an Array (Set 4) — the data. This set runs 4 cases: nums holds arrays of 16–32 items, with values from -40 to 80. The hidden cases are the largest of the set.

Example 1

runningSum()
Input
nums = [54, -36, 52, 62, 15, -21, 72, 27, 74, 0, 20, 62, 47, 58, 12, 44, 20, -6, 40, -13, 22, -39, -18, -2, 34, 24, 21, 33, 15]
Output
[54, 18, 70, 132, 147, 126, 198, 225, 299, 299, 319, 381, 428, 486, 498, 542, 562, 556, 596, 583, 605, 566, 548, 546, 580, 604, 625, 658, 673]

Why

`runningSum` returns `[54, 18, 70, 132, 147, 126, 198, 225, 299, 299, 319, 381, 428, 486, 498, 542, 562, 556, 596, 583, 605, 566, 548, 546, 580, 604, 625, 658, 673]` for this input.

Example 2

runningSum()
Input
nums = [-31, 73, 61, 72, 6, 58, 80, 45, 0, 79, -17, 15, -7, 56, 0, -2, -3, -2, -21, -9, 29]
Output
[-31, 42, 103, 175, 181, 239, 319, 364, 364, 443, 426, 441, 434, 490, 490, 488, 485, 483, 462, 453, 482]

Why

`runningSum` returns `[-31, 42, 103, 175, 181, 239, 319, 364, 364, 443, 426, 441, 434, 490, 490, 488, 485, 483, 462, 453, 482]` for this input.
Constraints
1 <= nums.length <= 10^4
-10^3 <= nums[i] <= 10^3
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysPrefix Sum

Implement runningSum in the editor and return the answer — printing it is never graded.