Skip to content

Instantly share code, notes, and snippets.

@rudrankriyam
Created January 20, 2020 07:59
Show Gist options
  • Select an option

  • Save rudrankriyam/2aaa5576612c8146021f959ca9b00b5f to your computer and use it in GitHub Desktop.

Select an option

Save rudrankriyam/2aaa5576612c8146021f959ca9b00b5f to your computer and use it in GitHub Desktop.
Example to use NOT operator
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