#K39832. String Rotation Check
String Rotation Check
String Rotation Check
Given two non-empty 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 a contiguous part from the end of s1 and appending it to the beginning.
For example, if s1 = "waterbottle" then s2 = "erbottlewat" is a valid rotation. You are required to read the two strings from the standard input (each on a separate line) and print True
if s2 is a rotation of s1 or False
otherwise.
Note: The check is case-sensitive and the strings will only contain printable characters.
inputFormat
The input consists of exactly two lines:
- The first line contains the string s1.
- The second line contains the string s2.
Both strings are non-empty and may contain spaces.
outputFormat
Output a single line with either True
or False
(without quotes). Output True
if s2 is a rotation of s1, and False
otherwise.
waterbottle
erbottlewat
True
</p>