We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3bc1561 commit a2c3238Copy full SHA for a2c3238
java/1480_Running_Sum_of_1d_Array.java
@@ -1,11 +1,8 @@
1
class Solution {
2
public int[] runningSum(int[] nums) {
3
if (nums.length <= 1) return nums;
4
- int accu = nums[0];
5
- for (int i = 1; i < nums.length; i++) {
6
- accu += nums[i];
7
- nums[i] = accu;
8
- }
+ for (int i = 1; i < nums.length; i++)
+ nums[i] += nums[i - 1];
9
return nums;
10
}
11
0 commit comments