CiscoOA #21
Find Longest Palindromic Substring
Estimated MediumJudge-ready
Topics (AI-labelled)PalindromesStrings
The string contains only uppercase English letters. Find the longest contiguous palindromic substring of length at least 2; if there are several longest results, output the lexicographically smallest string; if none exists, output None.
Input
One line containing a string of uppercase letters. The original gave no length bound; this site adds 1≤length≤1000.
Output
Output the chosen palindrome string or None.
Example 1
Input:
YABCCBAZ
Output:
ABCCBA
Example 2
Input:
ABC
Output:
None
Example 3
Input:
ZZXAA
Output:
AA
Example notes
The outputs of the three public examples are, in order: ABCCBA; None; AA. Verified by independent enumeration or direct simulation.
Editorial
Loading solution…