algorythms
Two Pointers
LC #125Easy

Valid Palindrome

Two Pointers
AmazonMicrosoftGoogleAppleMeta

Problem

A string is a palindrome if, after removing non-alphanumeric characters and lowercasing, it reads the same forward and backward.

stringtwo-pointers

Constraints

  • 1 ≤ s.length ≤ 2 × 10⁵
  • s consists only of printable ASCII characters

Example

Inputs = "A man, a plan, a canal: Panama"
Outputtrue
Why

After removing non-alphanumeric and lowercasing: "amanaplanacanalpanama" — reads the same both ways

Hints — reveal one at a time