#293. 字符串首尾子串匹配
字符串首尾子串匹配
String Prefix Suffix Match
Background
Congcong is learning string processing and encountered an interesting problem.
Problem Description
Given a string, if a length substring appears at both its beginning and end, return a string without the substring at the beginning, so "HelloHe" yields "lloHe". The substring may overlap with itself, so "Hi" yields "". Otherwise, return the original string unchanged.
Input Format
The input is given from standard input in the following format.
Output Format
Output to standard output in the following format.
Processed string
Sample
HelloHe
"lloHe"
HelloHi
"HelloHi"
Hi
""
Sample Explanation
Sample 1: The string 'HelloHe' has 'He' as its beginning substring and 'He' as its ending substring. They are the same, so removing the leading 'He' results in 'lloHe'. Sample 2: The string 'HelloHi' has 'He' as its beginning substring and 'Hi' as its ending substring. They are different, so the original string 'HelloHi' is returned. Sample 3: The string 'Hi' has 'Hi' as its beginning substring and 'Hi' as its ending substring. They are the same, so removing the leading 'Hi' results in an empty string ''.
Constraints
The length of string is between and .