Sunday, February 14, 2021

Leetcode Everyday: 1480. Running Sum of 1d Array. Easy

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/

No comments:

Post a Comment