Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2215. Find the Difference of Two Arrays
- func findDifference(_ nums1: [Int], _ nums2: [Int]) -> [[Int]] {
- let setOne = Set(nums1)
- let setTwo = Set(nums2)
- var firstNo = Set<Int>()
- var secondNo = Set<Int>()
- for num in setOne {
- if !setTwo.contains(num) {
- firstNo.insert(num)
- }
- }
- for num in setTwo {
- if !setOne.contains(num) {
- secondNo.insert(num)
- }
- }
- return [Array(firstNo), Array(secondNo)]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement