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
iHackSubhodip commented
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
}
`
iHackSubhodip commented
Problem Link -> https://leetcode.com/problems/valid-palindrome/description/
soapyigu commented
Good suggestion. Fixed.
iHackSubhodip commented
@soapyigu , Thanks for the correction.