Last active
August 2, 2023 19:06
-
-
Save alimir1/83b94be5fde4ef8b51ba6bf6044e78cd to your computer and use it in GitHub Desktop.
Check if string is palindrome Swift 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isPalindrome(_ word: String) -> Bool { | |
let word = word.lowercased().characters.filter{ $0 != " " } | |
for (i, character) in word.enumerated() { | |
if character != word[word.count-i-1] { | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anybody suggest how can achieve using high order func i.e Map or any ?