Palindrome Checker
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, ignoring punctuation, case, and spacing.
[ "A man a plan a canal Panama" ]
Explanation. After removing all non-alphanumeric characters, and converting to lowercase, 'amanaplanacanalpanama' is a palindrome.
[ "race a car" ]
Explanation. After proper formatting, 'raceacar' is not a palindrome.
[ " " ]
Explanation. An empty string or a string composed only of whitespace is considered a palindrome.
[ "0P" ]
Explanation. After considering alphanumeric characters and ignoring cases, '0p' is not a palindrome.
Follow-up: How would you handle strings with special characters or emojis?
The input string may contain letters (both uppercase and lowercase) and numeric characters.
- Views
- 2