Easy
Quiz
#125 Valid Palindrome
APPROACH
A string is a palindrome if, after lowercasing all letters and removing every non-alphanumeric character, it reads the same forwards and backwards.
Given a string s, return true if it qualifies as a palindrome, or false otherwise.
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.
Example 3:
Input: s = " "
Output: true
Explanation: s is an empty string "" after removing non-alphanumeric characters.
Since an empty string reads the same forward and backward, it is a palindrome.
1 of 4
1:00
What is the optimal approach for this problem?