-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathB Honest Coach
34 lines (30 loc) · 911 Bytes
/
B Honest Coach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
outer:while(t-->0){
int n = sc.nextInt();
int[] arr = new int[n];
for(int i =0;i<n;i++){
arr[i] = sc.nextInt();
}
int mi =Integer.MAX_VALUE;
int diff =Integer.MAX_VALUE;
Arrays.sort(arr);
for(int j =0;j<arr.length-1;j++){
diff = Math.abs(arr[j]-arr[j+1]);
if(diff<=mi){
mi= diff;
}
}
System.out.println(mi);
}
}
}