[백준] #1764 듣보잡 python
2022. 12. 30. 17:31
https://www.acmicpc.net/problem/1764
1764번: 듣보잡
첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. 이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다.
www.acmicpc.net
📕 설명 📕
Counter를 이용하여 개수를 세어 리스트에 담아서 출력하였다.
🧑🏻💻 나의 풀이 🧑🏻💻
from collections import Counter
N, M =map(int ,input().split())
i_cant_listen = []
i_cant_see = []
for i in range(N):
i_cant_listen.append(input())
for i in range(M):
i_cant_see.append(input())
C_i_cant_listen = Counter(i_cant_listen)
C_i_cant_see = Counter(i_cant_see)
result = []
for i in C_i_cant_listen:
if i in C_i_cant_see:
result.append(i)
print(len(result))
result.sort()
for i in result:
print(i)
'Programming > Algorithm' 카테고리의 다른 글
[백준] #11478 서로 다른 부분 문자열의 개수 python (0) | 2022.12.30 |
---|---|
[백준] #1269 대칭 차집합 python (0) | 2022.12.30 |
[백준] #10816 숫자 카드 2 python (0) | 2022.12.30 |
[백준] #1620 나는야 포켓몬 마스터 이다솜 python (0) | 2022.12.30 |
[백준] #14425 문자열 집합 python (0) | 2022.12.30 |