#C2114. Check for String Rotation

    ID: 45395 Type: Default 1000ms 256MiB

Check for String Rotation

Check for String Rotation

Given two non-empty strings s1 and s2, determine if s2 is a rotation of s1. A string s2 is considered a rotation of s1 if there exist two non-empty substrings \(A\) and \(B\) such that \(s1 = A + B\) and \(s2 = B + A\). Note that if either string is empty or the strings have different lengths, then s2 is not a rotation of s1.

Example:

  • If s1 = "waterbottle" and s2 = "erbottlewat", then the answer is True (as we can split s1 into "water" and "bottle").
  • If s1 = "hello" and s2 = "lloeh", then the answer is False.

inputFormat

The input consists of two lines:

  1. The first line contains the string s1.
  2. The second line contains the string s2.

outputFormat

Output a single line: True if s2 is a rotation of s1; otherwise, output False.

## sample
abcde
abcde
True