Dashboard
LC #125

Valid Palindrome

Pattern · ?AmazonMicrosoftGoogleAppleMeta

Problem

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

Constraints

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

Example

Input
s = "A man, a plan, a canal: Panama"
Output
true
Why
After removing non-alphanumeric and lowercasing: "amanaplanacanalpanama" — reads the same both ways

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗