#63. 寻找字符串镜像前缀后缀
寻找字符串镜像前缀后缀
Find Mirror End
Background
In a world of strings and patterns, Dawei is fascinated by symmetrical structures. He often challenges himself with puzzles involving strings that exhibit mirror-like properties.
Problem Description
Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or more characters at the very beginning of the given string, and at the very end of the string in reverse order (possibly overlapping). For example, the string "abXYZba" has the mirror end "ab".
Input Format
Input is given from standard input in the following format.
Output Format
Output is printed to standard output in the following format.
The mirror end string
Sample
abXYZba
"ab"
abca
"a"
aba
"aba"
Sample Explanation
For the string "abXYZba\