We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b31520a commit e601f6fCopy full SHA for e601f6f
Java/running-sum-of-1d-array.java
@@ -0,0 +1,25 @@
1
+/**
2
+* Running Sum of 1d Array
3
+*
4
+* Time Complexity - O(n)
5
+* Space Complexity - O(n)
6
7
+* Runtime: 0 ms, faster than 100.00% of Java online submissions
8
+*/
9
+class Solution {
10
+ public int[] runningSum(int[] nums) {
11
+
12
+ int len = nums.length;
13
+ int[] runningSumAr = new int[len];
14
15
+ int sumSoFar = 0;
16
17
+ for(int i=0; i<len; i++){
18
+ sumSoFar += nums[i];
19
20
+ runningSumAr[i] = sumSoFar;
21
+ }
22
23
+ return runningSumAr;
24
25
+}
0 commit comments