Running Sum of an Array (Set 13)

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 13) — 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 = [49, 37, 61, 7, -25, -30, 5, -6, 65, 4, -32, 28, 38, -4, 15, 74, -1, -25, 58, 29, 8, -12, -24, -39, -39, 40, -14, -12, 32, 76, -22, -2, 64, 13, -10, 69, 23, -27, -30, 50, 64, 25, 22, 36, 28, 34, 41, 69]
Output
[49, 86, 147, 154, 129, 99, 104, 98, 163, 167, 135, 163, 201, 197, 212, 286, 285, 260, 318, 347, 355, 343, 319, 280, 241, 281, 267, 255, 287, 363, 341, 339, 403, 416, 406, 475, 498, 471, 441, 491, 555, 580, 602, 638, 666, 700, 741, 810]

Why

`runningSum` returns `[49, 86, 147, 154, 129, 99, 104, 98, 163, 167, 135, 163, 201, 197, 212, 286, 285, 260, 318, 347, 355, 343, 319, 280, 241, 281, 267, 255, 287, 363, 341, 339, 403, 416, 406, 475, 498, 471, 441, 491, 555, 580, 602, 638, 666, 700, 741, 810]` for this input.

Example 2

runningSum()
Input
nums = [69, 43, 73, -3, 18, 76, 73, -38, 33, 3, -24, 10, 1, 11, 38, -8, -14, 5, 5, -1, 23, 57, 2, 60, 80, 78, 51, -22, 14, 68, -23, 11, 30, -26, -10, -14, 73, -23, -37, 5, -21, 15, 22, -35, -14, 15, 7, 5]
Output
[69, 112, 185, 182, 200, 276, 349, 311, 344, 347, 323, 333, 334, 345, 383, 375, 361, 366, 371, 370, 393, 450, 452, 512, 592, 670, 721, 699, 713, 781, 758, 769, 799, 773, 763, 749, 822, 799, 762, 767, 746, 761, 783, 748, 734, 749, 756, 761]

Why

`runningSum` returns `[69, 112, 185, 182, 200, 276, 349, 311, 344, 347, 323, 333, 334, 345, 383, 375, 361, 366, 371, 370, 393, 450, 452, 512, 592, 670, 721, 699, 713, 781, 758, 769, 799, 773, 763, 749, 822, 799, 762, 767, 746, 761, 783, 748, 734, 749, 756, 761]` 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.