ByteByteGo: Is Palindrome Valid
β’ 32 words β’ 1 min β’ updated
β οΈ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
ByteByteGo: Is Palindrome Valid:
python
def is_palindrome_valid(s: str) -> bool:
t = [c for c in s if c.isalnum()]
return t == t[::-1]Remove non-alphanumeric characters, compare the string to its reverse. β
Connections
Shared tags