Running Sum of an Array (Set 2)

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

Example 1

runningSum()
Input
nums = [-2, -33, 9, 49, -15, -8, -30, 54, 48, 9, 38, 65]
Output
[-2, -35, -26, 23, 8, 0, -30, 24, 72, 81, 119, 184]

Why

`runningSum` returns `[-2, -35, -26, 23, 8, 0, -30, 24, 72, 81, 119, 184]` for this input.

Example 2

runningSum()
Input
nums = [0, 61, 14, 68, 80, -7, -23, 70, 60, 71, 57, -11, 5, -29]
Output
[0, 61, 75, 143, 223, 216, 193, 263, 323, 394, 451, 440, 445, 416]

Why

`runningSum` returns `[0, 61, 75, 143, 223, 216, 193, 263, 323, 394, 451, 440, 445, 416]` 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.