Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Valid Palindrome

Easy
stringtwo-pointers

A phrase is a palindrome if, after lowercasing and removing all non-alphanumeric characters, it reads the same forwards and backwards. Return true if s is a palindrome.

Input: one line s (may contain spaces and punctuation). Output: true or false.

Example 1
Input:
A man, a plan, a canal: Panama
Output:
true
Example 2
Input:
race a car
Output:
false

Constraints

  • 1 ≤ s.length ≤ 2·10^5
  • s consists of printable ASCII characters.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.