1764 : 듣보잡

서희찬·2021년 11월 12일
0

백준

목록 보기
72/105

문제

코드

import sys 
input = sys.stdin.readline


n,m = map(int,input().split()) 
cantHear=[input().strip() for i in range(n)]
cantSee =[input().strip() for i in range(m)]

#집합을 만들어주고 리스트로 형변환 
#교집합 찾는다 
cant =list(set(cantHear)& set(cantSee)) 
print(len(cant))

for cants in sorted(cant):
    print(cants)

해설

집합을 이용하면 간단하게 풀수있는 문제이다.
리스트를 입력받고 집합으로 변환후 교집합을 얻어서 리스트로 변환해주고 출력을 하면 된다.

profile
Carnegie Mellon University Robotics Institute | Research Associate | Developing For Our Lives, 세상에 기여하는 삶을 살고자 개발하고 있습니다

0개의 댓글

관련 채용 정보