Skip to content

Commit 38832b6

Browse files
committed
feat: solution for problem 1480
1 parent 061431a commit 38832b6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

1480.running-sum-of-1-d-array.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* @lc app=leetcode id=1480 lang=cpp
3+
*
4+
* [1480] Running Sum of 1d Array
5+
*/
6+
7+
// @lc code=start
8+
class Solution
9+
{
10+
public:
11+
vector<int> runningSum(vector<int> &nums)
12+
{
13+
14+
vector<int> res;
15+
int sum = 0;
16+
for (int i = 0; i < nums.size(); i++)
17+
{ // O(n)
18+
sum += nums[i];
19+
res.push_back(sum);
20+
}
21+
return res;
22+
}
23+
};
24+
// @lc code=end

0 commit comments

Comments
 (0)