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 | 29 | 30 |
Tags
- SWIFT
- rxdatasources
- uikit toast
- button configuration
- swift navigationcontroller
- DP
- RxSwift
- 타임라인 포맷팅
- BFS
- identifiable
- swift dashed line
- task cancel
- claen architecture
- custombottomsheet
- Tuist
- coordinator
- custom ui
- swift 점선
- swift concurrency
- paragraph style
- swift custom ui
- traits
- custom navigation bar
- task cancellation
- UIKit
- reactorkit
- tusit font 추가 방법
- domain data
- swift 백준
- swift bottomsheet
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 |