망나니 AWOS의 일상
article thumbnail

문제 풀이

집합 같은 경우 set() 함수를 이용하면 쉽게 풀 수 있다. 

set() 함수는 중복을 허용하지 않으므로 수식으로 나타내 보면 아래의 수식처럼 나타낼 수 있다.

A U B - (A ∩ B)

합집합 같은경우 union 함수, 교집합 같은 경우 intersection 함수를 사용하면 된다.

 

완성된 코드!!👍😊

n, m = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
print(len(A.union(B) - A.intersection(B)))
profile

망나니 AWOS의 일상

@AWOS

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!