Running Sum of an Array (Set 6)

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

Example 1

runningSum()
Input
nums = [47, 3, 19, 47, 51, 12, -8, 56, 62, -20, -24, 46, 60, 38, 18, 23, 39, 61, 29, 39, -9, 45, -25, 10, 8]
Output
[47, 50, 69, 116, 167, 179, 171, 227, 289, 269, 245, 291, 351, 389, 407, 430, 469, 530, 559, 598, 589, 634, 609, 619, 627]

Why

`runningSum` returns `[47, 50, 69, 116, 167, 179, 171, 227, 289, 269, 245, 291, 351, 389, 407, 430, 469, 530, 559, 598, 589, 634, 609, 619, 627]` for this input.

Example 2

runningSum()
Input
nums = [50, 59, 7, -32, -16, -24, 79, -14, 73, -10, -21, 52, 54, -29, -7, 65, -2, 4, 30, -17, 19, 25, -36, -25, 22, 3, -19, -10, 67]
Output
[50, 109, 116, 84, 68, 44, 123, 109, 182, 172, 151, 203, 257, 228, 221, 286, 284, 288, 318, 301, 320, 345, 309, 284, 306, 309, 290, 280, 347]

Why

`runningSum` returns `[50, 109, 116, 84, 68, 44, 123, 109, 182, 172, 151, 203, 257, 228, 221, 286, 284, 288, 318, 301, 320, 345, 309, 284, 306, 309, 290, 280, 347]` 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.