Loading practice problems…
Loading your practice workspace…
Loading code editor…
4 / 29
Sign in
Algorithms/Two Pointers

Valid Palindrome

easy20 min

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing every non-alphanumeric character, it reads the same forward and backward.

Given a string s, return true when it is a palindrome and false otherwise.

Example 1

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

Outputtrue

The normalized string is "amanaplanacanalpanama".

Example 2

Inputs = "race a car"

Outputfalse

The normalized string is "raceacar".

Constraints

  • 1 ≤ s.length ≤ 200,000
  • s contains printable ASCII characters.
Two PointersStrings