Zero To DSAZero To DSA
Privacy Policy
Longest Substring Without Repeating Characters

Valid Palindrome

easy
Time: O(n)
Space: O(1)

A phrase is a palindrome if it reads the same forward and backward after converting to lowercase and removing all non-alphanumeric characters. Given a string `s`, return true if it is a palindrome.

Constraints

  • 1 <= s.length <= 2 * 10⁵

Examples

Input: s = "A man, a plan, a canal: Panama"
Output: true
"amanaplanacanalpanama" is a palindrome.
Input: s = "race a car"
Output: false