#159EasyStrings & Two Pointers· Converging Pointers
Clean Palindrome Check
Input format
`s`: a string of printable ASCII characters (it contains no double quote and no backslash).
Output format
`true` if the cleaned string reads the same in both directions, otherwise `false`.
Examples
Input: s = "A man, a plan, a canal: Panama"
Output: true
Dropping spaces and punctuation and lowercasing gives "amanaplanacanalpanama", which is a palindrome.
Input: s = "race a car"
Output: false
The cleaned text "raceacar" reads "racaecar" backwards, so it is not a palindrome.
Input: s = " .,"
Output: true
Nothing remains after cleaning, and an empty string counts as a palindrome.
Constraints
- 0 <= s.length <= 2 * 10^5
- s contains printable ASCII characters only; it contains no double quote and no backslash.
Study first
- #two-pointers
- #strings
- #palindrome