Practice/Meta/Leetcode 125. Valid Palindrome
CodingMust
Given a string, determine if it becomes a palindrome after performing two preprocessing steps: converting all uppercase letters to lowercase and removing all non-alphanumeric characters (keeping only letters and digits).
A palindrome is a sequence that reads the same forwards and backwards.
true if the processed string is a palindrome, false otherwisetrue)Example 1:
Input: s = "racecar" Output: true Explanation: The string is already lowercase and alphanumeric, and reads the same forwards and backwards.
Example 2:
Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: After removing spaces and punctuation and converting to lowercase: "amanaplanacanalpanama" which is a palindrome.
Example 3:
Input: s = "hello world" Output: false Explanation: After cleaning: "helloworld" which is not a palindrome.
Example 4:
Input: s = " " Output: true Explanation: After removing non-alphanumeric characters, we have an empty string which is considered a palindrome.