Given a string, determine if it is a palindrome considering only alphanumeric characters and ignoring case. An empty string is considered a valid palindrome.
For example, "A man, a plan, a canal: Panama" is a palindrome because after removing non-alphanumeric characters and converting to lowercase, it reads "amanaplanacanalpanama", which is the same forwards and backwards. However, "race a car" becomes "raceacar", which is not a palindrome.
Explain your approach, how you handle non-alphanumeric characters, and analyze the time and space complexity.
How to approach it
- Hint 1
Compare characters from both ends moving inward. What data structure or technique lets you do this efficiently?
- Hint 2
Use two pointers: one at the start and one at the end. Skip non-alphanumeric characters.
- Hint 3
Convert characters to lowercase before comparing. No need to build a cleaned string first.
Ready to answer it out loud?
Record your answer in 1:00 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.
Practising needs an invite code. Join the waitlist and we’ll send you one.