mirror of
https://github.com/harivansh-afk/veet-code.git
synced 2026-04-15 08:03:46 +00:00
33 lines
844 B
Python
33 lines
844 B
Python
"""
|
|
Palindrome Checker
|
|
|
|
You're building a word game that awards bonus points for palindromes.
|
|
Given a string, determine if it reads the same forwards and backwards,
|
|
ignoring case and non-alphanumeric characters.
|
|
|
|
Example 1:
|
|
Input: text = "A man, a plan, a canal: Panama"
|
|
Output: True
|
|
Explanation: "amanaplanacanalpanama" is a palindrome
|
|
|
|
Example 2:
|
|
Input: text = "race a car"
|
|
Output: False
|
|
Explanation: "raceacar" is not a palindrome
|
|
|
|
Example 3:
|
|
Input: text = " "
|
|
Output: True
|
|
Explanation: Empty after removing non-alphanumeric
|
|
|
|
Constraints:
|
|
- Input is always a string
|
|
- Ignore spaces, punctuation, and case
|
|
- Empty string is considered a palindrome
|
|
"""
|
|
|
|
|
|
def is_palindrome(text: str) -> bool:
|
|
"""Return True if text is a palindrome, False otherwise."""
|
|
pass # Your implementation here
|
|
|