# Maximum Difference in Positions

Contributed by
Arindam Majumder
Last Updated: 23 Feb, 2023
Medium
0/80
Avg time to solve 30 mins
Success Rate 70 %
Share

## Problem Statement

#### Note:

``````Return 0, if there are no such two students present.
``````
Detailed explanation ( Input/output format, Notes, Images )
##### Constraints:
``````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
``````
##### Sample Input 1:
``````2
3
1 2 3
8
4 3 2 8 1 3 3 3
``````
##### Sample Output 1:
``````2
6
``````
##### Explanation of sample input 1:
``````In the first test case, the students with marks 1 and 3 ( 1<= 3) have the maximum difference between their positions.

In the second test case, the students with marks 3 and 3 ( 3<= 3) have the maximum difference between their positions, 7 - 1 = 6.
``````
##### Sample Input 2:
``````2
2
5 6
2
6 5
``````
##### Sample Output 2:
``````1
0
``````
##### Explanation for sample input 2:
``````In the first test case, the students with marks 5 and 6 ( 5 <= 6) have the maximum difference between their positions.

In the second test case, there are no such students present.
``````
Auto
Console