9. Palindrome Checker
EasyStrings~10 min
A palindrome reads the same forwards and backwards once you ignore case, spaces and punctuation.
Return true if the input is a palindrome and false otherwise. "A man, a plan, a canal: Panama" is a palindrome.
Examples
Example 1
- Input:
- str = "racecar"
- Output:
- true
Example 2
- Input:
- str = "A man, a plan, a canal: Panama"
- Output:
- true
- Why:
- Ignoring case and punctuation it reads the same both ways.
Example 3
- Input:
- str = "hello"
- Output:
- false
Constraints
0 <= str.length <= 2000An empty string counts as a palindrome.