Running Sum of 1d Array

Given an array nums, define the running sum of the array as runningSum[i] = sum(nums[0]…nums[i]).

Return the running sum of nums.

Example 1
Inputnums = [1,2,3,4]
Output[1,3,6,10]
Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
Example 2
Inputnums = [1,1,1,1,1]
Output[1,2,3,4,5]
Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].

Constraints

  • 1 <= nums.length <= 1000
  • -10^6 <= nums[i] <= 10^6

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate