Check String Rotations
Problem statement
Return whether second is a cyclic rotation of first: move some prefix of the first string to its end without changing either part internally. Zero rotation is allowed. Two empty strings are rotations; strings of different lengths are not.
Function
areRotations(first: String, second: String) → booleanExamples
Example 1
first = "abcde"second = "cdeab"return = trueMove the prefix ab after cde to obtain cdeab.
Example 2
first = "abcde"second = "abced"return = falseNo prefix cut preserves the order needed to produce abced.
Constraints
0 <= first.length <= 2000.0 <= second.length <= 2000.- Both strings contain only lowercase English letters a through z.