Running Sum of an Array (Set 14)

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

Example 1

runningSum()
Input
nums = [33, -28, 35, -21, 13, 49, 34, 11, 13, 47, 75, -36, -5, 36, 20, 49, 50, 29, -20, 31, -19, -31, 37, 25, 33, -1, -5, -29, 11, 71, -26, -24, -37, 33, 50, -35, 55, 48, 39, -28, -33, -9, 20, -25, -15, 2, 19, -18]
Output
[33, 5, 40, 19, 32, 81, 115, 126, 139, 186, 261, 225, 220, 256, 276, 325, 375, 404, 384, 415, 396, 365, 402, 427, 460, 459, 454, 425, 436, 507, 481, 457, 420, 453, 503, 468, 523, 571, 610, 582, 549, 540, 560, 535, 520, 522, 541, 523]

Why

`runningSum` returns `[33, 5, 40, 19, 32, 81, 115, 126, 139, 186, 261, 225, 220, 256, 276, 325, 375, 404, 384, 415, 396, 365, 402, 427, 460, 459, 454, 425, 436, 507, 481, 457, 420, 453, 503, 468, 523, 571, 610, 582, 549, 540, 560, 535, 520, 522, 541, 523]` for this input.

Example 2

runningSum()
Input
nums = [-18, 60, -21, 3, 25, 75, -27, -32, 67, 45, 78, -14, -33, 21, 66, 37, 14, -4, 51, 23, 54, -38, 25, 55, -34, 79, -35, -1, 77, 50, -13, 12, -12, -30, -28, -37, 80, -10, 8, 67, 22, 39, 52, 64, 65, 42, 43, 62]
Output
[-18, 42, 21, 24, 49, 124, 97, 65, 132, 177, 255, 241, 208, 229, 295, 332, 346, 342, 393, 416, 470, 432, 457, 512, 478, 557, 522, 521, 598, 648, 635, 647, 635, 605, 577, 540, 620, 610, 618, 685, 707, 746, 798, 862, 927, 969, 1012, 1074]

Why

`runningSum` returns `[-18, 42, 21, 24, 49, 124, 97, 65, 132, 177, 255, 241, 208, 229, 295, 332, 346, 342, 393, 416, 470, 432, 457, 512, 478, 557, 522, 521, 598, 648, 635, 647, 635, 605, 577, 540, 620, 610, 618, 685, 707, 746, 798, 862, 927, 969, 1012, 1074]` 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.