File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 169
169
1470|[ Shuffle the Array] ( ./1470-shuffle-the-array.js ) |Easy|
170
170
1472|[ Design Browser History] ( ./1472-design-browser-history.js ) |Medium|
171
171
1475|[ Final Prices With a Special Discount in a Shop] ( ./1475-final-prices-with-a-special-discount-in-a-shop.js ) |Easy|
172
+ 1480|[ Running Sum of 1d Array] ( ./1480-running-sum-of-1d-array.js ) |Easy|
172
173
1486|[ XOR Operation in an Array] ( ./1486-xor-operation-in-an-array.js ) |Easy|
173
174
1598|[ Crawler Log Folder] ( ./1598-crawler-log-folder.js ) |Easy|
174
175
1780|[ Check if Number is a Sum of Powers of Three] ( ./1780-check-if-number-is-a-sum-of-powers-of-three.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1480. Running Sum of 1d Array
3
+ * https://leetcode.com/problems/running-sum-of-1d-array/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given an array nums. We define a running sum of an array as
7
+ * runningSum[i] = sum(nums[0]…nums[i]).
8
+ *
9
+ * Return the running sum of nums.
10
+ */
11
+
12
+ /**
13
+ * @param {number[] } nums
14
+ * @return {number[] }
15
+ */
16
+ var runningSum = function ( nums ) {
17
+ for ( let i = 1 ; i < nums . length ; i ++ ) {
18
+ nums [ i ] = nums [ i - 1 ] + nums [ i ] ;
19
+ }
20
+ return nums ;
21
+ } ;
You can’t perform that action at this time.
0 commit comments