import java.util.Arrays;
import java.util.Scanner;
public class LeetCode_RunningSum {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] arr = {1,2,3,4};
System.out.println(Arrays.toString(out(arr)));
}
static int[] out(int[] nums){
int sum = 0;
int[] arr = new int[nums.length];
for (int i = 0; i < nums.length; i++){
sum += nums[i];
arr[i] = sum;
}
return arr;
}
}
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;
}
}
class Solution {
public int[] runningSum(int[] nums) {
int[] sol = new int[nums.length];
sol[0] = nums[0];
for(int i = 1; i < nums.length; i++) {
sol[i] = sol[i-1] + nums[i];
}
return sol;
}
}
// Example: runningSum([1,3,6,9]) = [1, 4, 10, 19] = [1, 1+3, 1+3+6, 1+3+6+9]