New update is available. Click here to update.

Last Updated: 13 Mar, 2021

Difficulty: Moderate

```
Return 0, if there are no such two students present.
```

```
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a single integer ‘N’ which denotes the number of students in the row.
The second line of each test case contains the ‘N’ space-separated integers in which the “i-th” number represents the marks of the “i-th” student.
```

```
For each test case, print the maximum difference between the two students described above. If, there are no such students then print 0.
Output for every test case will be printed in a separate line.
```

```
You don’t need to print anything; It has already been taken care of.
```

```
1 <= T <= 50
2 <= N <= 10000
0 <= arr[ i ] <= 10^5
Where ‘T’ is the number of test cases.
Where 'N' is the number of students in the row and “arr[ i ]” denotes the marks of “i-th” student.
Time limit: 1 sec
```

Popular Interview Problems: