Palindrome Check

Easy~10 min

Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring case.

A palindrome reads the same forward and backward. For example, "A man, a plan, a canal: Panama" is a palindrome when you strip non-alphanumeric characters and ignore case.

Examples

Example 1
Input: s = "A man, a plan, a canal: Panama"
Output: true
Explanation: After removing non-alphanumeric characters and lowering case: "amanaplanacanalpanama", which reads the same forward and backward.
Example 2
Input: s = "race a car"
Output: false
Explanation: After cleaning: "raceacar" is not a palindrome.
Example 3
Input: s = " "
Output: true
Explanation: After removing non-alphanumeric characters, the string is empty. An empty string is considered a palindrome.

Constraints

  • 0 <= s.length <= 2 * 10^5
  • s consists of printable ASCII characters.
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run