Back to problems Solve on LeetCode →
← 3Sum Two Sum II →

Valid Palindrome

LeetCode 125 • Easy • Two Pointers

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

TimeO(n)each char at most once
SpaceO(1)two pointers
Left: Right: Result:
Left
Right
Skip (non-alnum)
Match
Left
Right
Result
pending
Ready
Press Play. Two pointers converge: skip non-alphanumeric, compare case-insensitive. Return False on mismatch, True if pointers meet.