#C1029. Check String Rotation

    ID: 39478 Type: Default 1000ms 256MiB

Check String Rotation

Check String Rotation

Given two strings s1 and s2, determine whether s2 is a rotation of s1. A string s2 is considered a rotation of s1 if it can be obtained by taking some prefix of s1 and moving it to the end of s1. Formally, if s1 has length n and there exists an integer k (with 0 ≤ k ≤ n) such that

\( s_2 = s_{1}[k:] + s_{1}[0:k] \)

Your task is to implement an efficient algorithm that checks this property using string operations. The recommended approach is to verify whether s2 is a substring of s1 + s1.

inputFormat

The input consists of two lines:

  • The first line contains the string s1.
  • The second line contains the string s2.

Both strings contain only printable ASCII characters.

outputFormat

Output a single line containing True if s2 is a rotation of s1, and False otherwise.

## sample
waterbottle
erbottlewat
True