Running Sum of an Array (Set 8)

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

Example 1

runningSum()
Input
nums = [-38, 0, -27, 57, 38, 16, 57, -17, -10, 24, -23, -39, 18, 41, 36, 73, 33, 63, 68, 54, 28, -20, -11, 66, 73, 21, 25, 61, 22, 20, 27, 72, 15, 28, -37, -4, 50, 39, 49, -9, 35]
Output
[-38, -38, -65, -8, 30, 46, 103, 86, 76, 100, 77, 38, 56, 97, 133, 206, 239, 302, 370, 424, 452, 432, 421, 487, 560, 581, 606, 667, 689, 709, 736, 808, 823, 851, 814, 810, 860, 899, 948, 939, 974]

Why

`runningSum` returns `[-38, -38, -65, -8, 30, 46, 103, 86, 76, 100, 77, 38, 56, 97, 133, 206, 239, 302, 370, 424, 452, 432, 421, 487, 560, 581, 606, 667, 689, 709, 736, 808, 823, 851, 814, 810, 860, 899, 948, 939, 974]` for this input.

Example 2

runningSum()
Input
nums = [9, 42, 65, 18, 80, 52, 71, -32, 32, 44, 74, 26, 27, 67, 57, 14, 1, 27, 49, 46, 13, 47, 59, 34, 35, -24, 15, -4, 75, -17, 24, 69, -19, 53, 16, -20, -4, -3, 76, 8, 59, 38, -25, 31, 66, -24, 39]
Output
[9, 51, 116, 134, 214, 266, 337, 305, 337, 381, 455, 481, 508, 575, 632, 646, 647, 674, 723, 769, 782, 829, 888, 922, 957, 933, 948, 944, 1019, 1002, 1026, 1095, 1076, 1129, 1145, 1125, 1121, 1118, 1194, 1202, 1261, 1299, 1274, 1305, 1371, 1347, 1386]

Why

`runningSum` returns `[9, 51, 116, 134, 214, 266, 337, 305, 337, 381, 455, 481, 508, 575, 632, 646, 647, 674, 723, 769, 782, 829, 888, 922, 957, 933, 948, 944, 1019, 1002, 1026, 1095, 1076, 1129, 1145, 1125, 1121, 1118, 1194, 1202, 1261, 1299, 1274, 1305, 1371, 1347, 1386]` 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.