Running Sum of an Array (Set 3)

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

Example 1

runningSum()
Input
nums = [23, 52, 43, 67, -3, 48, 44, 72, 29, 80, 9, -35, 61, -36, 7, -22]
Output
[23, 75, 118, 185, 182, 230, 274, 346, 375, 455, 464, 429, 490, 454, 461, 439]

Why

`runningSum` returns `[23, 75, 118, 185, 182, 230, 274, 346, 375, 455, 464, 429, 490, 454, 461, 439]` for this input.

Example 2

runningSum()
Input
nums = [15, 75, 66, -30, 10, -10, 43, 25, 62, -30, 3, 26, -5]
Output
[15, 90, 156, 126, 136, 126, 169, 194, 256, 226, 229, 255, 250]

Why

`runningSum` returns `[15, 90, 156, 126, 136, 126, 169, 194, 256, 226, 229, 255, 250]` 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.