Your question is Palindrome Check with Cleanup. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
BCG X may process text from reports and client communications where punctuation, spaces, and capitalization should not affect comparisons. Given a string, determine whether it is a palindrome after ignoring every non-alphanumeric character and treating uppercase and lowercase letters as equal.
Implement is_palindrome(s), where s is a string. Return True if the filtered string reads identically from left to right and right to left; otherwise, return False. The filtered string contains only letters and digits. An empty filtered string is considered a palindrome.
Use a two-pointer approach that compares characters from both ends without creating a separate filtered string.
def is_palindrome(s):