Created
January 20, 2020 07:59
-
-
Save rudrankriyam/2aaa5576612c8146021f959ca9b00b5f to your computer and use it in GitHub Desktop.
Example to use NOT operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func singleNumber(_ nums: [Int]) -> Int { | |
| var set = Set<Int>() | |
| for number in nums { | |
| if !set.contains(number) { | |
| set.insert(number) | |
| } else { | |
| set.remove(number) | |
| } | |
| } | |
| return set.first ?? 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment