Skip to content

Instantly share code, notes, and snippets.

@BrianLitwin
Created May 24, 2018 14:49
Show Gist options
  • Save BrianLitwin/d2c8d03cd15304bb41030d693ef0fabe to your computer and use it in GitHub Desktop.
Save BrianLitwin/d2c8d03cd15304bb41030d693ef0fabe to your computer and use it in GitHub Desktop.
func isUnique(string: String) -> Bool {
var charSet = Set<Character>()
for character in string {
guard charSet.contains(character) == false else { return false }
charSet.insert(character)
}
return true
}
// if charSet.contains(character) {
// return false
// } else {
// charSet.insert(character)
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment