Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Clean palindrome check

Hardware interview practice

Clean palindrome check

EasyStringsSystemVerilog

Return 1 when a string is a palindrome after ignoring punctuation and letter case. Only alphanumeric characters participate in the comparison.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
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

  1. Skip non-alphanumeric bytes from both ends.
  2. Compare letters case-insensitively.
  3. Treat an empty cleaned string as a palindrome.
Continue practicing

Related questions

Linked ListsRemove the nth node from the end→ArraysMove zeros to the end→
asic.fyi · Learn silicon end to end.info@asic.fyi