Valid Palindrome
Python data engineering interview problem. Difficulty: intermediate. Pattern: Two Pointers. About 14 minutes. Part of the Pro drill bank.
Check palindrome ignoring non-alphanumeric and case. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
User-entered text often contains spaces, commas and punctuation, but a palindrome check should compare the meaningful letters and digits only. Return True when the input reads the same from both directions after removing non-alphanumeric characters and ignoring case. Return False when the cleaned text differs from its reverse. Write the function is_palindrome(s: str) -> bool. 'A man, a plan, a canal: Panama' becomes amanaplanacanalpanama, which is the same forwards and backwards. The starter file already has the function name and the harness print lines. Keep them, and fill only the function body.
Requirements
- Ignore spaces and punctuation.
- Compare uppercase and lowercase letters as the same character.
- Return a Python boolean, True or False.
Constraints
- s is a string and the comparison is case-insensitive only after filtering alphanumeric characters.
- The return type is bool; do not return the cleaned string.
Examples
Input: is_palindrome('A man, a plan, a canal: Panama') Output: True Alnum letters form a palindrome.
Topics: lakebench, python, palindrome, strings.
More Python interview questions · All interview problems · Learn data engineering
Valid Palindrome
Interview-style drill: Check palindrome ignoring non-alphanumeric and case.
Implement `is_palindrome(s: str) -> bool` comparing only alphanumeric characters, case-insensitive. Example: `"A man, a plan, a canal: Panama"` → `True`. Keep the harness.