https://www.acmicpc.net/problem/10816
10816번: 숫자 카드 2
첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,
www.acmicpc.net
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split("\n");
const dic = {};
const N = Number(input[0]);
const M = Number(input[2]);
const sang = input[1].split(" ");
const comp = input[3].split(" ");
const answer = [];
sang.forEach(d => {
if(dic[d] === undefined) dic[d] = 1;
else dic[d] ++;
});
comp.forEach((d) => {
if(dic[d] !== undefined ) answer.push(dic[d]);
else answer.push(0);
})
console.log(answer.join(" "));
728x90
'Algorithm&CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [1764] 집합과 맵 - 듣보잡 (0) | 2023.02.23 |
---|---|
[Baekjoon] [1269] 집합과 맵 - 대칭 차집합 (0) | 2023.02.23 |
[Baekjoon] [10815] 집합과 맵 - 숫자 카드 (0) | 2023.02.23 |
[Beakjoon] [14425] 집합과 맵 - 문자열 집합 (0) | 2023.02.23 |
[Beakjoon] [1436] 브루트 포스 - 영화감독 숌 (0) | 2023.02.23 |