#K56717. String Rotation Check
String Rotation Check
String Rotation Check
Given two strings s1 and s2, determine if s2 is a rotation of s1. A string s2 is a rotation of s1 if it can be obtained by taking a contiguous part from the end of s1 and appending it to the beginning of s1. Equivalently, if s2 is a substring of s1 concatenated with itself, then s2 is a rotation of s1.
For example, if s1 = "waterbottle"
and s2 = "erbottlewat"
, then s2
is a rotation of s1
.
Note: Two strings of different lengths cannot be rotations of each other.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains the string s1
and the second line contains the string s2
.
outputFormat
Output to standard output (stdout) a single line containing True
if s2
is a rotation of s1
, and False
otherwise.## sample
waterbottle
erbottlewat
True