TopcoderArchiveVisit Topcoder
SRM5 Jun 2012
SRM 563

FoxAndHandleEasy

Problem statement, definition, constraints, and public examples.

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".

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

  1. "Ciel"
    "CieCiell"
    Returns: "Yes"
    She can insert "Ciel" between "Cie" and "l".
  2. "Ciel"
    "FoxCiel"
    Returns: "No"
    Each string obtained by expanding S="Ciel" has exactly 8 letters.
  3. "FoxCiel"
    "FoxFoxCielCiel"
    Returns: "Yes"
  4. "FoxCiel"
    "FoxCielCielFox"
    Returns: "No"
  5. "Ha"
    "HaHaHaHa"
    Returns: "No"
  6. "TheHandleCanBeVeryLong"
    "TheHandleCanBeVeryLong"
    Returns: "No"
  7. "Long"
    "LongLong"
    Returns: "Yes"
Back to all problems