String Palindrome

Languages

Given a string str, determine if it is a palindrome. Return true if it is, and false otherwise.

A string is a palindrome if, after changing all uppercase letters to lowercase and discarding all non-alphanumeric characters, it remains identical when read forward and backward. Alphanumeric characters consist of both letters and numbers.

Input

  • str: string: A string

Examples

Input: str = "No 'x' in Nixon"
Output: true
Explanation: After removing non-alphanumeric characters and converting to lowercase, the string becomes 'noxinnixon', which is a palindrome.
Input: str = "Was it a car or a cat I saw?"
Output: true
Explanation: After removing non-alphanumeric characters and converting to lowercase, the string becomes 'wasitacaroracatisaw', which is a palindrome.
Input: str = "tab a cat"
Output: false
Explanation: After removing non-alphanumeric characters and converting to lowercase, the string becomes 'tabacat', which is not a palindrome.

Constraints

  • 1 <= str.length <= 1000
  • The string str consists only of printable ASCII characters