#293. 字符串首尾子串匹配

    ID: 293 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-1gesp3字符串条件结构

字符串首尾子串匹配

String Prefix Suffix Match

Background

Congcong is learning string processing and encountered an interesting problem.

Problem Description

Given a string, if a length 22 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.

SS

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 SS is between 00 and 10510^5.