#C758. Palindromic String Analysis Challenge
Palindromic String Analysis Challenge
Palindromic String Analysis Challenge
This problem involves analyzing strings with respect to palindromes. You are given one or more input strings, each provided on a separate line. The input terminates with the line "END" (which should not be processed). For each input string, you are required to determine whether the string is a palindrome, ignoring spaces, punctuation, and capitalization, and also to find its longest palindromic substring.
A palindrome is a string that reads the same backward as forward when ignoring differences in case, spaces and punctuation. The longest palindromic substring is the longest contiguous sequence within the string that is itself a palindrome. In case there are multiple substrings of maximum length, output the first one found.
inputFormat
The input consists of multiple lines. Each line contains a single string. The final line of input will be the string "END", which signals the end of input and should not be processed.
outputFormat
For each input string (excluding the terminating "END"), output one line containing two values separated by a space:
- The word "YES" if the input string is a palindrome and "NO" otherwise.
- The longest palindromic substring of the input string.
madam
racecar
apple
noon
babad
END
YES madam
YES racecar
NO pp
YES noon
NO bab
</p>