Asked at
Running Sum of 1d Array
EasyVerifiedArrayPrefix Sum~10 min
Given nums, return its running sum, where result[i] is the sum of nums[0..i] inclusive.
The input arrives as a single array nums.
Examples
in[1, 2, 3, 4]
out[1, 3, 6, 10]
Running sum is [1, 1+2, 1+2+3, 1+2+3+4].
in[1, 1, 1, 1, 1]
out[1, 2, 3, 4, 5]
Each element adds 1 to the previous total.
Constraints
- 1 ≤ nums.length ≤ 1000
- -10⁶ ≤ nums[i] ≤ 10⁶
Get help
🔑
Sign in to solve
Sign in to write, run, and submit your solution — and to pick up where your iOS flow left off.