## Problem – Running Sum of 1d Array LeetCode Solution

Given an array `nums`

. We define a running sum of an array as `runningSum[i] = sum(nums[0]…nums[i])`

.

Return the running sum of `nums`

.

**Example 1:**

```
Input: nums = [1,2,3,4]
Output: [1,3,6,10]
Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
```

**Example 2:**

```
Input: nums = [1,1,1,1,1]
Output: [1,2,3,4,5]
Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
```

**Example 3:**

```
Input: nums = [3,1,2,10,1]
Output: [3,4,6,16,17]
```

**Constraints:**

`1 <= nums.length <= 1000`

`-10^6 <= nums[i] <= 10^6`

### Running Sum of 1d Array LeetCode Solution in Java

```
public int[] runningSum(int[] nums) {
int i = 1;
while (i<nums.length){
nums[i]+=nums[i-1];
i++;
}
return nums;
}
```

### Running Sum of 1d Array LeetCode Solution in C++

```
vector<int> runningSum(vector<int>& nums) {
int i = 1;
while (i<nums.size()){
nums[i]+=nums[i-1];
i++;
}
return nums;
}
```

### Running Sum of 1d Array LeetCode Solution in Python

```
def runningSum(self, nums):
i = 1
while i<len(nums):
nums[i]+=nums[i-1]
i+=1
return nums
```

##### Running Sum of 1d Array LeetCode Solution Review:

In our experience, we suggest you solve this Running Sum of 1d Array LeetCode Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Running Sum of 1d Array LeetCode Solution

**Find on LeetCode**

##### Conclusion:

I hope this Running Sum of 1d Array LeetCode Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Coding Solutions >>**

**LeetCode Solutions**

**Hacker Rank Solutions**

**CodeChef Solutions**