LEETCODE RUNNING SUM OF 1D ARRAY (1 MAY- 7 MAY)
class Solution {
public int[] runningSum(int[] nums) {
int index=0;
int sum=0;
for(int i=0;i<nums.length;i++){
sum=sum+nums[i];
nums[index]=sum;
index++;
}
return nums;
}
}
class Solution {
public int[] runningSum(int[] nums) {
int index=0;
int sum=0;
for(int i=0;i<nums.length;i++){
sum=sum+nums[i];
nums[index]=sum;
index++;
}
return nums;
}
}
Comments
Post a Comment