LeetCode 125

Valid Palindrome

Concepts:

Two Pointer

Description: A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Given a string s, return true if it is a palindrome, or false otherwise.

Optimal Approach

Initialize two pointers, one at the start and one at the end of the string. Move the pointers inwards, skipping non-alphanumeric characters.

Time: O(n)

Space: O(1)

All Problems