Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Running Sum of 1d Array Leetcode

class Solution {
    public int[] runningSum(int[] nums) {
    int[] ans = new int[nums.length];
    ans[0] = nums[0];
    for (int i = 1; i < nums.length; i++)
        ans[i] = ans[i-1] + nums[i];
    return ans;
    }
}
 
PREVIOUS NEXT
Tagged: #Running #Sum #Array #Leetcode
ADD COMMENT
Topic
Name
9+3 =