Clean Palindrome
A palindrome can be checked even inside a regular phrase with spaces, punctuation, and mixed letter case. Given a string s, consider only letters and digits, and ignore case. Return True if the cleaned string reads the same from left to right and from right to left, otherwise return False.
Примеры
Ввод
"A man, a plan, a canal: Panama"Вывод
TrueВвод
"race a car"Вывод
FalseВвод
" "Вывод
TrueНужно реализовать
def is_palindrome(s: str) -> bool:
Теги
stringstwo-pointers
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible 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
"ab_a"Expected
True6
Input
"abc"Expected
FalseFocus radio
Paused · SomaFM · Fluid