LeetCode 1480. 一维数组的动态和

https://leetcode-cn.com/problems/running-sum-of-1d-array/

Java

    public int[] runningSum(int[] nums) {
        if (nums.length <= 0) {
            return new int[0];
        }
        for (int i = 1; i < nums.length; i++) {
            nums[i] += nums[i - 1];
        }
        return nums;
    }

  

 

posted @ 2020-10-02 16:30  Risfeng  阅读(156)  评论(0编辑  收藏  举报