Maximum Gap
Submissions: 8425   Accuracy:

35.54%

  Difficulty: Easy   Marks: 2

Given an unsorted array. Your task is to find the maximum difference between the successive elements in its sorted form.

Input:
The first line of input contains an integer T,  number of test cases. Following T lines contains an integer N denoting the size of array and next line followed contains the array elements.

Output:
Print the maximum gap between the successive elements.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 106
1 ≤ A[i] ≤ 106

Example:
Input:
1
3
1 10 5

Output:
5

Explanation:
Testcase 1:
The maximum difference between successive elements of array is 5(abs(5-10)).

** For More Input/Output Examples Use 'Expected Output' option **

Author: shef5


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.