-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay30.java
More file actions
33 lines (33 loc) · 834 Bytes
/
Copy pathDay30.java
File metadata and controls
33 lines (33 loc) · 834 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 Day30{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the Number of Test Cases");
int size = in.nextInt();
int size2;
String out = "";
String res = "";
for (int i=0;i<size ;i++ ) {
System.out.println("Enter the Size for Test Case "+(i+1));
size2 = in.nextInt();
System.out.println("Enter the "+size2+" elements");
int arr[] = new int[size2];
for (int j=0;j<size2 ;j++ ) {
arr[j] = in.nextInt();
}
Arrays.sort(arr);
for (int k=0;k<size2 ;k++ ) {
if (k==0) {
res = res+Integer.toString(arr[k]);
}else if(res.contains(Integer.toString(arr[k]))){
continue;
}else{
res = res+Integer.toString(arr[k]);
}
}
out = out+res;
res = "";
}
System.out.println(out);
}
}