Valid Palindrome

Given a string `s`, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Return `true` if it is a palindrome, or `false` otherwise.

Input Format

s = input string

Output Format

true if s is a palindrome ignoring non-alphanumeric characters, false otherwise

Constraints

Examples

Example 1:

Input:

s = "A man, a plan, a canal: Panama"

Output:

true

Explanation:

Ignoring punctuation and case, it reads 'amanaplanacanalpanama' which is a palindrome.

Example 2:

Input:

s = "race a car"

Output:

false

Explanation:

"raceacar" is not a palindrome.

Example 3:

Input:

s = ""

Output:

true

Explanation:

Empty string is a valid palindrome.

Loading...
Valid Palindrome - Two Pointers DSA Problem