#K54722. Longest Palindrome Finder
Longest Palindrome Finder
Longest Palindrome Finder
This problem requires you to find the longest palindrome within a given text string. A palindrome is a sequence of characters that reads the same backward as forward. Note that while determining palindromes, you must ignore any non‐alphanumeric characters and treat uppercase and lowercase letters as equivalent.
The input will be a string that may include spaces, punctuation, or even multiple lines. You need to preprocess the string to remove any non-alphanumeric characters and convert all letters to lowercase, and then determine the longest palindromic substring using an appropriate algorithm. If there are multiple palindromes of the same maximum length, you may return the one that appears first.
The algorithm should be efficient enough to handle reasonably long strings.
inputFormat
The input is provided via standard input (stdin) and consists of a single string. This string may include spaces, punctuation, and can span multiple lines.
outputFormat
Output the longest palindrome found in the processed text (only alphanumeric characters considered and case ignored) to standard output (stdout).## sample
racecar
racecar