#C8686. Rotation Transformation Check
Rotation Transformation Check
Rotation Transformation Check
Given two strings \(s_1\) and \(s_2\), determine whether \(s_2\) can be obtained by a rotation of \(s_1\). More formally, check if \(s_2\) is a substring of \(s_1+s_1\). For example, if \(s_1 = \texttt{abcde}\) and \(s_2 = \texttt{cdeab}\), then the output should be true
.
If the two strings are of different lengths, \(s_2\) cannot be a rotation of \(s_1\) and the answer should be false
.
Input Note: The input consists of two lines. The first line is the original string \(s_1\) and the second line is the target string \(s_2\).
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains the original string \(s_1\).
- The second line contains the target string \(s_2\).
Both strings will consist of printable characters. They may be empty as well.
outputFormat
Output a single line to standard output (stdout) that contains either true
or false
(without quotes). Output true
if \(s_2\) can be obtained by a rotation of \(s_1\), otherwise output false
.
abcde
cdeab
true