Solution: Valid Palindrome
Let's solve the Valid Palindrome problem using the Two Pointers pattern.
Statement
Given a string, s
, return TRUE
if it is a palindrome; otherwise, return FALSE
.
A phrase is considered a palindrome if it reads the same backward as forward after converting all uppercase letters to lowercase and removing any characters that are not letters or numbers. Only alphanumeric characters (letters and digits) are taken into account.
Constraints:
s.length
s
consists only of printable ASCII characters.
Solution
So far, you‘ve probably brainstormed some approaches and have an idea of how to solve this problem. Let’s explore some of these approaches and figure out which one to follow based on considerations such as time complexity and any implementation constraints.
Naive approach
A naive approach to checking if a ...