1480. Running Sum of 1d Array
Question
Given an array
nums
. We define a running sum of an array asrunningSum[i] = sum(nums[0]…nums[i])
.Return the running sum of
nums
.
Solution
类似动态规划,遍历数组,并将当前位置的元素和上一个位置的元素进行加和。
Code
1 | class Solution { |
1480. Running Sum of 1d Array
https://xuanhe95.github.io/2022/06/01/1480-Running-Sum-of-1d-Array/