Skip to content

Instantly share code, notes, and snippets.

@azurast
Last active August 21, 2021 10:27
Show Gist options
  • Save azurast/d116d44f426208403cedcbd1e802d864 to your computer and use it in GitHub Desktop.
Save azurast/d116d44f426208403cedcbd1e802d864 to your computer and use it in GitHub Desktop.
Swift solution to the Hackkerrank Two Strings problem - Final Attempt
/*
Final Attempt
8/8 test cases passed
*/
func twoStrings(s1: String, s2: String) -> String {
let uniqueCharacters = Set(s2)
for char in uniqueCharacters {
if s1.contains(char) {
return "YES"
}
}
return "NO"
}
twoStrings(s1: "hello", s2: "world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment