Problem Statement
Fox Ciel has a new favorite string operation that works as follows:
She takes two copies of some string X, and inserts one copy somewhere into the other copy of the same string.
(She can also insert it at the beginning or, equivalently, at the end.)
This operation is called expansion of the string X.
For example, if X = "Ciel", she can expand it to "CielCiel", "CCieliel", "CiCielel", or "CieCiell".
You are given two Strings: S and T. Return "Yes" (quotes for clarity) if T can be obtained by expanding S exactly once. Otherwise, return "No".
You are given two Strings: S and T. Return "Yes" (quotes for clarity) if T can be obtained by expanding S exactly once. Otherwise, return "No".
Definition
- Class:
- FoxAndHandleEasy
- Method:
- isPossible
- Parameters:
- String, String
- Returns:
- String
- Method signature:
- String isPossible(String S, String T)
- (be sure your method is public)
Constraints
- S will contain between 1 and 50 characters, inclusive.
- T will contain between 1 and 50 characters, inclusive.
- Both S and T will contain uppercase and lowercase letters only ('A'-'Z' and 'a'-'z').
Examples
"Ciel"
"CieCiell"
Returns: "Yes"
She can insert "Ciel" between "Cie" and "l"."Ciel"
"FoxCiel"
Returns: "No"
Each string obtained by expanding S="Ciel" has exactly 8 letters."FoxCiel"
"FoxFoxCielCiel"
Returns: "Yes"
"FoxCiel"
"FoxCielCielFox"
Returns: "No"
"Ha"
"HaHaHaHa"
Returns: "No"
"TheHandleCanBeVeryLong"
"TheHandleCanBeVeryLong"
Returns: "No"
"Long"
"LongLong"
Returns: "Yes"