-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyPaste.java
More file actions
31 lines (27 loc) · 844 Bytes
/
CopyPaste.java
File metadata and controls
31 lines (27 loc) · 844 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
package problems.codechef;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
/**
* Created by arpit on 25/12/16.
*/
public class CopyPaste {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t,n;
String[]s;
HashSet<Integer>set=new HashSet<>();
t=Integer.parseInt(br.readLine());
while (t-->0){
n=Integer.parseInt(br.readLine());
s=br.readLine().split("\\s");
for (int i = 0; i < n; i++) {
set.add(Integer.parseInt(s[i]));
}
//Ans is no. of distinct elements in array.
System.out.println(set.size());
set.clear();
}
}
}