#C10860. Rotational String Match
Rotational String Match
Rotational String Match
Given two strings S and T, determine whether T can be obtained by rotating S.
A rotation is defined as transferring the first character of the string to its end. More formally, for a string \(S = s_0s_1\ldots s_{n-1}\), a rotation by \(k\) positions results in a new string \[ T = s_k s_{k+1} \ldots s_{n-1} s_0 s_1 \ldots s_{k-1} \] for some \(0 \le k < n\). If there exists such a rotation that makes T equal to the rotated string, output "Yes"; otherwise, output "No".
It is guaranteed that the strings consist of printable characters without spaces.
inputFormat
The input consists of two strings provided via standard input. The first line contains the string S and the second line contains the string T.
outputFormat
Output a single line with either Yes
or No
depending on whether T can be obtained by rotating S.
hello
lohel
Yes