https://www.acmicpc.net/problem/1269
1269번: 대칭 차집합
첫째 줄에 집합 A의 원소의 개수와 집합 B의 원소의 개수가 빈 칸을 사이에 두고 주어진다. 둘째 줄에는 집합 A의 모든 원소가, 셋째 줄에는 집합 B의 모든 원소가 빈 칸을 사이에 두고 각각 주어
www.acmicpc.net
# 1269 - Python 3
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
answer = list(set(arr1) ^ set(arr2)) # arr1, arr2의 대칭차집합 구하기
print(len(answer))
< line 10 >
- list(set(arr1) ^ set(arr2))
: arr1, arr2의 대칭 차집합 반환
'코딩' 카테고리의 다른 글
| [Python] 백준 #10872. 팩토리얼 (0) | 2023.03.18 |
|---|---|
| [Python] 백준 #11478. 서로 다른 부분 문자열의 개수 (0) | 2023.03.18 |
| [Python] 백준 #1764. 듣보잡 (0) | 2023.03.18 |
| [Python] 백준 #10816. 숫자 카드 2 (0) | 2023.03.18 |
| [Python] 백준 #1620. 나는야 포켓몬 마스터 이다솜 (0) | 2023.03.17 |