1480. Running Sum of 1d Array
Last updated
Last updated
/**
* Time complexity : O(N), Where N is the size of the array.
* Space complexity : O(1)
*/
class Solution {
public int[] runningSum(int[] nums) {
if(nums != null && nums.length > 1) {
for(int i = 1; i < nums.length; i++) {
nums[i] += nums[i-1];
}
}
return nums;
}
}