Running Sum of an Array (Set 5)

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

Example 1

runningSum()
Input
nums = [0, 70, 78, 58, 58, -14, 43, 69, 8, 41, -33, -14, 75, -14, -18, 3, -24, 39, 78, 76, -37, 1, 78, -21, 67, 57, 34, 44, -32, 79, 3, 1]
Output
[0, 70, 148, 206, 264, 250, 293, 362, 370, 411, 378, 364, 439, 425, 407, 410, 386, 425, 503, 579, 542, 543, 621, 600, 667, 724, 758, 802, 770, 849, 852, 853]

Why

`runningSum` returns `[0, 70, 148, 206, 264, 250, 293, 362, 370, 411, 378, 364, 439, 425, 407, 410, 386, 425, 503, 579, 542, 543, 621, 600, 667, 724, 758, 802, 770, 849, 852, 853]` for this input.

Example 2

runningSum()
Input
nums = [30, -2, 63, -12, -9, -14, 14, 6, 71, 70, -34, 35, -11, 45, 46, -24, 7, -10, -12, -30, -33, 46, 71, 74, 8, 70, 80, 0, -2, 59, 12, 55, -35]
Output
[30, 28, 91, 79, 70, 56, 70, 76, 147, 217, 183, 218, 207, 252, 298, 274, 281, 271, 259, 229, 196, 242, 313, 387, 395, 465, 545, 545, 543, 602, 614, 669, 634]

Why

`runningSum` returns `[30, 28, 91, 79, 70, 56, 70, 76, 147, 217, 183, 218, 207, 252, 298, 274, 281, 271, 259, 229, 196, 242, 313, 387, 395, 465, 545, 545, 543, 602, 614, 669, 634]` 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.