File tree 3 files changed +35
-1
lines changed
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @return {number[] }
4
+ */
5
+ const runningSum = ( nums ) => {
6
+ let acc = 0 ;
7
+ for ( let i = 0 ; i < nums . length ; i ++ ) {
8
+ console . log ( `nums[i]:${ nums [ i ] } , acc:${ acc } ` )
9
+ let tmpAcc = acc + nums [ i ] ;
10
+ nums [ i ] += acc ;
11
+ acc = tmpAcc ;
12
+ // console.log(nums[i])
13
+ }
14
+ return nums ;
15
+ } ;
16
+
17
+ let x = null ;
18
+ x = runningSum ( [ 1 , 2 , 3 , 4 ] ) ;
19
+ console . log ( "Result" )
20
+ console . log ( x )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @return {number[] }
4
+ */
5
+ const runningSum = ( nums ) => {
6
+ let acc = 0 ;
7
+ for ( let i = 0 ; i < nums . length ; i ++ ) {
8
+ let tmpAcc = acc + nums [ i ] ;
9
+ nums [ i ] += acc ;
10
+ acc = tmpAcc ;
11
+ }
12
+ return nums ;
13
+ } ;
Original file line number Diff line number Diff line change 72
72
- [ 1161. Maximum Level Sum of a Binary Tree] ( ./1161/ )
73
73
- [ 1187. Make Array Strictly Increasing] ( ./1187/ )
74
74
- [ 1365. How Many Numbers Are Smaller Than the Current Number] ( ./1365/ )
75
+ - [ 1480. Running Sum of 1d Array] ( ./1480/ )
75
76
- [ 1512. Number of Good Pairs] ( ./1512/ )
76
77
- [ 1569. Number of Ways to Reorder Array to Get Same BST] ( ./1569/ )
77
78
- [ 1672. Richest Customer Wealth] ( ./1672/ )
@@ -127,7 +128,7 @@ Batch create:
127
128
NOTE: JS IS HERE
128
129
-->
129
130
``` ssh
130
- chapter=2373 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
131
+ chapter=1480 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
131
132
```
132
133
> then you can use ` x ` for quick debug.
133
134
You can’t perform that action at this time.
0 commit comments