Search topics...
All Problems

Valid Palindrome

Solution Approach
Was this helpful?
EasystringExpected: O(n) time, O(1) space
two-pointers

Problem

Given a string, determine if it is a palindrome considering only alphanumeric characters and ignoring cases.

Example 1:

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

Example 2:

Input: s = "race a car"
Output: false
Explanation: "raceacar" is not a palindrome.
Reference solution unlocks after your first submission
Loading...