soapyigu/LeetCode-Swift

Code is not getting complied on Xcode 9.4.1 for "https://github.com/soapyigu/LeetCode-Swift/blob/master/String/ValidPalindrome.swift"

iHackSubhodip opened this issue · 3 comments

Slight Correction..

`func isPalindrome(_ s: String) -> Bool {
// Make String into an array of lowercase Characters
let characters = s.lowercased()

// Only keep alphanumeric characters.
let cleanedCharacter = characters.filter { character in
    return character.description.rangeOfCharacter(from: CharacterSet.alphanumerics) != nil
}

// Making array of cleaned characters
let cleaned = Array(cleanedCharacter)

// Compare values at mirroring indices.
let total = cleaned.count
for i in 0 ..< total/2 {
    if cleaned[i] != cleaned[total - 1 - i] {
        return false
    }
}
return true

}
`

Good suggestion. Fixed.

@soapyigu , Thanks for the correction.