문제에서 제시한 입력으로 출력은 알맞게 나오는데 틀렸다고 한다. 그 이유를 모름
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int m = sc.nextInt();
Map<Integer, Integer> map = new LinkedHashMap<>();
for(int i = 0; i < m; i++) {
map.put(sc.nextInt(), 0);
}
for (int j : arr) {
if (map.containsKey(j)) {
map.put(j, map.get(j) + 1);
}
}
map.forEach((key, value) -> System.out.print(value + " "));
}
728x90
반응형
'매일코테 > 못 푼 문제' 카테고리의 다른 글
조합 0의 개수 - 시간초과 (0) | 2022.08.14 |
---|---|
백준 14단계 5번 (0) | 2022.08.12 |
참외밭 (2) | 2022.08.06 |
백준 10단계 no.4 (0) | 2022.07.26 |
백준 9단계 no.4 (0) | 2022.07.26 |