Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7008433

Browse files
committedDec 2, 2021
Add solution #1480
1 parent 43d7b9d commit 7008433

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
1470|[Shuffle the Array](./1470-shuffle-the-array.js)|Easy|
170170
1472|[Design Browser History](./1472-design-browser-history.js)|Medium|
171171
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|
172173
1486|[XOR Operation in an Array](./1486-xor-operation-in-an-array.js)|Easy|
173174
1598|[Crawler Log Folder](./1598-crawler-log-folder.js)|Easy|
174175
1780|[Check if Number is a Sum of Powers of Three](./1780-check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
};

0 commit comments

Comments
 (0)
Please sign in to comment.