Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Hash
- func disappearedNumbers(nums: [Int]) -> [Int] {
- if nums.isEmpty {
- return []
- }
- var set = Set(nums)
- var missingNumms = [Int]()
- for i in 1...nums.count {
- if !set.contains(i) {
- missingNumms.append(i)
- }
- }
- return missingNumms
- }
- let nums = disappearedNumbers(nums: [4,3,2,7,8,2,3,1])
- print(nums)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement