Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- BFS
- RxSwift
- task cancel
- swift dashed line
- swift 백준
- swift custom ui
- task cancellation
- swift 점선
- custombottomsheet
- custom ui
- Tuist
- identifiable
- reactorkit
- uikit toast
- 버튼 피드백
- coordinator
- swift existential type
- 드롭다운 버튼
- swift associated type
- scene delegate
- swift opaque type
- UIKit
- OAtuh 2.0
- swift navigationcontroller
- button configuration
- swift bottomsheet
- DP
- swift concurrency
- SWIFT
- custom navigation bar
Archives
- Today
- Total
김경록의 앱 개발 여정
[Swift 백준] 1269 대칭 차집합 본문

풀이
두 집합 a,b 에서
(a - b).count + (b-a).count 를 구하는 문제입니다.
Swift에서 여집합을 구하는 함수는 'subtract()'와 'subtracting()' 입니다.
둘의 차이점은
| subtract | subtracting |
| 원본 변형 | 새로운 집합 return |
이니 편의를 위해 'subtracting'을 사용해줍니다
let nm = readLine()!.split(separator: " ").map{Int($0)!}
let a = Set(readLine()!.split(separator: " ").map{Int($0)!})
let b = Set(readLine()!.split(separator: " ").map{Int($0)!})
let aCount = a.subtracting(b).count
let bCount = b.subtracting(a).count
print(aCount + bCount)
'Algorithm' 카테고리의 다른 글
| [Swift 백준] 2212 센서 (0) | 2025.04.15 |
|---|---|
| [Swift 백준] 10610 30 (0) | 2025.04.14 |
| [Swift 백준] 11052 카드 구매하기 (0) | 2025.04.03 |
| [Swift 백준] 1475 방 번호 (0) | 2025.03.31 |
| [Swift 백준] 9465 스티커 (0) | 2025.03.28 |