Clean Palindrome Check
Real phrases often contain spaces, punctuation, and mixed letter case, but those can be noise when checking a palindrome. Given a string s, consider only letters and digits. Ignore case, so A and a count as the same character. Return True if the cleaned string reads the same forward and backward; otherwise, return False.
Примеры
Ввод
"A man, a plan, a canal: Panama"Вывод
TrueВвод
"race a car"Вывод
FalseВвод
" "Вывод
TrueНужно реализовать
def is_palindrome(s: str) -> bool:
Теги
stringstwo-pointers
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänVisible tests
1
Input
"A man, a plan, a canal: Panama"Expected
True2
Input
"race a car"Expected
False3
Input
" "Expected
True4
Input
"0P"Expected
False5
Input
"Was it a car or a cat I saw?"Expected
True6
Input
"abccba"Expected
TrueFocus radio
Paused · SomaFM · Fluid