#K42652. Rotated String Verification
Rotated String Verification
Rotated String Verification
You are given two strings S
and P
. Your task is to determine whether S
is a rotated version of P
. A string S
is said to be a rotated version of P
if you can obtain S
by performing a rotation on P
by any number of positions.
For example, consider the string P = "amazon"
:
- If you rotate
P
by 2 positions, you get"azonam"
, which meansS = "azonam"
is a rotated version ofP
. - On the other hand,
S = "hello"
is not a rotated version ofP
ifP
is different.
You need to write a program that reads two strings from standard input and prints True
if S
is a rotated version of P
; otherwise, print False
.
Note: The comparison is case-sensitive and any rotation that brings P
to S
is considered valid.
inputFormat
The input consists of two lines:
- The first line contains the string
S
. - The second line contains the string
P
.
outputFormat
Output a single line containing either True
or False
depending on whether S
is a rotated version of P
or not.
amazon
azonam
True