Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension String {
- func removingWhitespaces() -> String {
- return components(separatedBy: .whitespaces).joined()
- }
- }
- func isAnagram(_ firstWord:String, _ secondWord:String ) -> Bool{
- let charSetofFirstWord = NSCountedSet(array:Array(firstWord.removingWhitespaces()))
- let charSetofSecondWord = NSCountedSet(array:Array(secondWord.removingWhitespaces()))
- return charSetofFirstWord == charSetofSecondWord
- }
Add Comment
Please, Sign In to add comment