fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. // Write your code here
  6. Scanner sc = new Scanner(System.in);
  7. int t = sc.nextInt();
  8. while(t-- > 0){
  9. int n = sc.nextInt();
  10. int[] a = new int[n];
  11. int[] freq = new int[100001];
  12. for(int i = 0 ; i < n ; i++){
  13. a[i] = sc.nextInt();
  14. freq[a[i]]++;
  15. }
  16. int count = 0;
  17. for(int i = 0 ; i < freq.length ; i++){
  18. if(freq[i] > 0) count++;
  19. }
  20. System.out.println(count);
  21. }
  22. }
  23. }
Success #stdin #stdout 0.11s 56984KB
stdin
4
1
5
2
1 1
3
1 2 3
4
2 1 2 2
stdout
1
1
3
2