백준 알고리즘 (Baekjoon Algorithm)

[파이썬] 백준 알고리즘 No.1269 대칭 차집합

Universe_lee 2023. 2. 18. 16:42

나의 코드

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = set(list(map(int, input().split())))
b = set(list(map(int, input().split())))

print(len((a.difference(b)).union((b.difference(a)))))

 

풀이 방법

set 자료형

 

print(len((a - b) | (b - a)))

위와 같이 표현할 수도 있다.