public class Solution {
public int[] RunningSum(int[] nums) {
var accum = 0;
var list = new List<int>();
foreach (var n in nums) {
accum += n;
list.Add(accum);
}
return list.ToArray();
}
}
Source:
https://leetcode.com/problems/running-sum-of-1d-array/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Sunday, February 14, 2021
Leetcode Everyday: 1480. Running Sum of 1d Array. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment