Hardware interview practice
Clean palindrome check
Return 1 when a string is a palindrome after ignoring punctuation and letter case. Only alphanumeric characters participate in the comparison.
Reviewed example
Work through one case
Input
s = "A man, a plan, a canal: Panama!"Expected output
1 (palindrome)Removing punctuation and folding case produces "amanaplanacanalpanama", which reads the same in both directions.
What to cover
Requirements
- Skip non-alphanumeric bytes from both ends.
- Compare letters case-insensitively.
- Treat an empty cleaned string as a palindrome.
