-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlocked.java
More file actions
33 lines (33 loc) · 944 Bytes
/
Copy pathBlocked.java
File metadata and controls
33 lines (33 loc) · 944 Bytes
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
import java.util.*;
public class Blocked{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s=sc.next();
StringBuilder sb=new StringBuilder();
if(s==null)return;
int t=Integer.parseInt(s);
while(t-- > 0){
int n=sc.nextInt();
Integer []a=new Integer[n];
Set<Integer>ue=new HashSet<>();
boolean flag=false;
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
if(!ue.add(a[i])){
flag=true;
}
}
if(flag){
sb.append("-1\n");
}else{
Arrays.sort(a,Collections.reverseOrder());
for(int i=0;i<n;i++){
sb.append(a[i]).append(i== n - 1 ? "" : " ");
}
sb.append("\n");
}
}
System.out.print(sb);
sc.close();
}
}