Running Sum of an Array (Set 1)

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

Example 1

runningSum()
Input
nums = [72, -3, -35]
Output
[72, 69, 34]

Why

`runningSum` returns `[72, 69, 34]` for this input.

Example 2

runningSum()
Input
nums = [57, 38, 16, -38, 5, 10]
Output
[57, 95, 111, 73, 78, 88]

Why

`runningSum` returns `[57, 95, 111, 73, 78, 88]` 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.