Running Sum of an Array (Set 11)

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 11) — the data. This set runs 4 cases: nums holds arrays of 44–48 items, with values from -40 to 79. The hidden cases are the largest of the set.

Example 1

runningSum()
Input
nums = [55, -28, 36, 3, -22, -37, -23, 55, 47, 60, -24, -14, 67, 63, 60, 61, -31, -34, 54, 62, 59, 29, -32, -28, 53, 58, -31, -35, 33, -18, 2, 71, 62, 20, 76, -32, -37, 17, 21, 8, 7, 58, 55, 27]
Output
[55, 27, 63, 66, 44, 7, -16, 39, 86, 146, 122, 108, 175, 238, 298, 359, 328, 294, 348, 410, 469, 498, 466, 438, 491, 549, 518, 483, 516, 498, 500, 571, 633, 653, 729, 697, 660, 677, 698, 706, 713, 771, 826, 853]

Why

`runningSum` returns `[55, 27, 63, 66, 44, 7, -16, 39, 86, 146, 122, 108, 175, 238, 298, 359, 328, 294, 348, 410, 469, 498, 466, 438, 491, 549, 518, 483, 516, 498, 500, 571, 633, 653, 729, 697, 660, 677, 698, 706, 713, 771, 826, 853]` for this input.

Example 2

runningSum()
Input
nums = [9, 13, 24, 14, 34, 77, 2, -37, 70, 74, 73, 14, -22, -32, 2, 54, 5, 35, -39, 58, 41, 73, 76, 69, 79, 68, 33, -12, 25, -29, 52, 53, 58, -16, -40, -9, 12, 62, -3, -7, -1, 30, -17, 14]
Output
[9, 22, 46, 60, 94, 171, 173, 136, 206, 280, 353, 367, 345, 313, 315, 369, 374, 409, 370, 428, 469, 542, 618, 687, 766, 834, 867, 855, 880, 851, 903, 956, 1014, 998, 958, 949, 961, 1023, 1020, 1013, 1012, 1042, 1025, 1039]

Why

`runningSum` returns `[9, 22, 46, 60, 94, 171, 173, 136, 206, 280, 353, 367, 345, 313, 315, 369, 374, 409, 370, 428, 469, 542, 618, 687, 766, 834, 867, 855, 880, 851, 903, 956, 1014, 998, 958, 949, 961, 1023, 1020, 1013, 1012, 1042, 1025, 1039]` 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.