Set
을 활용한 문제
문제
https://www.acmicpc.net/problem/1822
내가 작성한 코드
Swift
let n = readLine()!.split(separator: " ").map { Int(String($0))! }
let a = readLine()!.split(separator: " ").map { Int(String($0))! }
let b = readLine()!.split(separator: " ").map { Int(String($0))! }
let ans = Set(a).subtracting(Set(b)).sorted()
print(ans.count)
print(ans.map { String($0) }.joined(separator: " "))