Valid Palindrome

easyTwo Pointerstwo pointers from both endsB75Solve on LeetCode#125

Part of Practice: Converging Pairs

Given a string s, decide whether it is a palindrome — reading the same forwards and backwards — after two cleanup steps: ignore every character that is not a letter or digit, and treat uppercase and lowercase letters as equal.

The string can be up to 200,000 characters and may contain spaces, punctuation, or nothing alphanumeric at all; an empty (or effectively empty) string counts as a palindrome.

Examples

Input:
s = "A man, a plan, a canal: Panama"
Output:
true

Keeping only letters and digits and lowercasing gives "amanaplanacanalpanama", which reads the same both ways.

Input:
s = "race a car"
Output:
false

"raceacar" is not the same reversed ("racaecar").

Input:
s = " "
Output:
true

After removing non-alphanumeric characters nothing is left, and an empty string is a palindrome.

Hints

One at a time — struggle first, peek second.

Your thinking space — verify on LeetCode, then mark it.