Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

Ninja has an array ‘A’ of size ‘N’. He recently created a topic ‘Complete Sum’ and defined the term ‘completeSum[i]’ = Sum ( A[0] … A[i] ).

Output the complete sum array of array ‘A’.

```
N = 3
A = [ 1, 2, 3 ]
Explanation :
Complete sum for index 0 is ‘A[0]=1’.
Complete sum for index 1 is ‘A[0] + A[1]’ = 3.
Complete sum for index 2 is ‘A[0] + A[1] + A[2]’ = 6.
So, we output [ 1, 3, 6 ].
```

Detailed explanation

```
1 <= T <= 5
1 <= N <= 10^5
0 <= A[i] <= 10^4
Time Limit : 1 sec
```

```
2
3
3 1 2
4
1 1 1 1
```

```
3 4 6
1 2 3 4
```

```
For test case 1 we have,
Complete sum for index 0 is ‘A[0]=3’.
Complete sum for index 1 is ‘A[0] + A[1]’ = 4.
Complete sum for index 2 is ‘A[0] + A[1] + A[2]’ = 6.
So, we output [ 3, 4, 6 ].
For test case 2 we have,
Complete sum for index 0 is ‘A[0]=1’.
Complete sum for index 1 is ‘A[0] + A[1]’ = 2.
Complete sum for index 2 is ‘A[0] + A[1] + A[2]’ = 3.
Complete sum for index 3 is ‘A[0] + A[1] + A[2] + A[3]’ = 4.
So, we output [ 1, 2, 3, 4 ].
```

```
2
2
7 2
5
4 1 7 5 1
```

```
7 9
4 5 12 17 18
```