Want to solve this problem? Login now to get access to solve the problems

Problem

Submissions

Solution

Leaderboard

Coming soon

2

Difficulty: EASY

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

Suggest Edit

```
1 bus can be boarded from the first bus stop which means that 1 bus originates from the first bus stop.
3 buses can be boarded from the second bus stop which means that (3-1 = 2) buses originate from the second bus stop. This is because the bus originating from the first stop will stop at the second stop as well.
4 buses can be boarded from the third bus stop which means that (4-1 = 3) buses originate from the third bus stop. This is because the bus originating from the first stop will stop at the third stop as well.
3 buses can be boarded from the fourth bus stop which means that (3-3 = 0) buses originate from the fourth bus stop. This is because the buses originating from the first and second stop will stop at the fourth stop as well.
So the final vector would be: [1 2 3 0].
```

```
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of each test case contains a single integer N representing the length of the vector.
The second line of each test case contains N space-separated integers denoting the elements of the given vector.
```

```
For each test case, print N integers denoting the number of buses originating from each bus stop from 1 to N.
```

```
1 ≤ T ≤ 50
1 ≤ N ≤ 10^4
1 ≤ Ai ≤ 10^6
Time Limit : 1 sec
```

```
The given vector uses 1-based indexing.
You are not required to print the expected output, it has already been taken care of. Just implement the function.
```

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

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

```
For the first test case, the explanation is already given.
For the second test case, the given vector is: [1 2 3 4 5].
1 bus can be boarded from the first bus stop which means that 1 bus originates from the first bus stop.
2 buses can be boarded from the second bus stop which means that (2-1 = 1) buses originate from the second bus stop. This is because the bus originating from the first stop will stop at the second stop as well.
3 buses can be boarded from the third bus stop which means that (3-1 = 2) buses originate from the third bus stop. This is because the bus originating from the first stop will stop at the third stop as well.
4 buses can be boarded from the fourth bus stop which means that (4-1-1 = 1) buses originate from the fourth bus stop. This is because the buses originating from the first and second stop will stop at the fourth stop as well.
5 buses can be boarded from the fifth bus stop which means that (5-1 = 4) buses originate from the fifth bus stop. This is because the bus originating from the first stop will stop at the fifth stop as well.
So the final vector would be: [1 1 2 2 4]
For the third test case, the given vector is: [4 4 4].
4 buses can be boarded from the first bus stop which means that 4 buses originate from the first bus stop.
4 buses can be boarded from the second bus stop which means that (4-4 = 0) buses originate from the second bus stop. This is because the bus originating from the first stop will stop at the second stop as well.
4 buses can be boarded from the third bus stop which means that (4-4 = 0) buses originate from the third bus stop. This is because the bus originating from the first stop will stop at the third stop as well.
So the final vector would be: [4 0 0]
```

```
3
1
5
2
5 6
4
1 3 6 8
```

```
5
5 1
1 2 5 5
```

Want to solve this problem? Login now to get access to solve the problems