-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ02007.java
More file actions
31 lines (28 loc) · 943 Bytes
/
J02007.java
File metadata and controls
31 lines (28 loc) · 943 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 CODE_PTIT;
import java.util.*;
public class J02007 {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int t;
t = inp.nextInt();
for(int k = 1; k <= t; k++){
Map<Integer, Integer> map = new LinkedHashMap<>();
int n = inp.nextInt();
for(int i = 0; i < n; i++){
int x = inp.nextInt();
if(map.containsKey(x)){
int cnt = map.get(x);
cnt++;
map.put(x, cnt);
}
else{
map.put(x, 1);
}
}
System.out.println("Test " + k +":");
for(Map.Entry<Integer, Integer> entry : map.entrySet()){
System.out.println(entry.getKey() + " xuat hien " + entry.getValue() + " lan");
}
}
}
}