All Blind 75 questions

Valid Palindrome

FreeTwo pointersEasy9 of 75

The problem

Check whether a string reads the same in both directions after ignoring non-alphanumeric characters and letter case. An empty cleaned string counts as a palindrome.

Example

"Was it a car or a cat I saw?" → true

Need a hint?

You can skip punctuation without building a cleaned copy.

Write pseudocode, trace the example, or note an edge case. This scratchpad does not run code.

Notes stay in this browser when storage is available.

Read the solution approach

Place pointers at both ends. Advance each past characters that are not letters or digits. Compare normalized characters, failing on a mismatch, then move inward. Stop when the pointers meet or cross.

Complexity

O(n) time and O(1) extra space.

Before moving on, explain why the algorithm is correct and trace a boundary case without looking at the approach.