📜  运行一维数组之和 Java 代码示例

📅  最后修改于: 2022-03-11 14:52:19.541000             🧑  作者: Mango

代码示例2
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;
    }
}