#C1062. Check String Rotation
Check String Rotation
Check String Rotation
You are given two strings s and t. Determine whether t is a rotation of s. In other words, check if there exists an integer k (where 0 \leq k < n and n is the length of s) such that the string t can be obtained by rotating s by k positions.
A key observation is that t is a rotation of s if and only if it is a substring of s+s. That is, the condition can be mathematically stated as:
\( t \subseteq s+s \)
Note that if s and t are of different lengths, then t cannot be a rotation of s.
inputFormat
The input is provided via stdin consisting of exactly two lines. The first line contains the string s and the second line contains the string t.
outputFormat
Output to stdout a single line containing either True
if t is a rotation of s, otherwise False
.
abcde
cdeab
True