Guest User

Untitled

a guest
Mar 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. extension String {
  2. func removingWhitespaces() -> String {
  3. return components(separatedBy: .whitespaces).joined()
  4. }
  5. }
  6.  
  7. func isAnagram(_ firstWord:String, _ secondWord:String ) -> Bool{
  8. let charSetofFirstWord = NSCountedSet(array:Array(firstWord.removingWhitespaces()))
  9. let charSetofSecondWord = NSCountedSet(array:Array(secondWord.removingWhitespaces()))
  10. return charSetofFirstWord == charSetofSecondWord
  11. }
Add Comment
Please, Sign In to add comment