#K95262. Check if a String is a Rotated Version

    ID: 38825 Type: Default 1000ms 256MiB

Check if a String is a Rotated Version

Check if a String is a Rotated Version

In this problem, you are given two strings. Your task is to determine whether the second string is a rotated version of the first string. A string (B) is considered a rotated version of string (A) if there exists some integer (k) such that when (A) is rotated left by (k) positions, the result is (B). For example, if (A = \texttt{hello}) then rotating it by 2 positions gives (\texttt{llohe}), which means (\texttt{llohe}) is a rotated version of (\texttt{hello}).

Note: The rotation operation does not change the length of the string. Formally, for two strings (A) and (B), if (|A| \neq |B|) then (B) cannot be a rotated version of (A).

inputFormat

The input is read from standard input (stdin). It consists of two lines:

  • The first line contains the original string.
  • The second line contains the string to be checked.

outputFormat

Print to standard output (stdout) True if the second string is a rotated version of the first string, and False otherwise.## sample

hello
llohe
True