Rotation of Another String
Given two alphabet (can be lower and/or uppercase) strings s0
and s1
, determine if one is a rotation of the other.
Constraints
1 ≤ n ≤ 200,000
wheren
is the length ofs0
1 ≤ m ≤ 200,000
wherem
is the length ofs1
https://binarysearch.com/problems/Rotation-of-Another-String
Examples
Example 1
Input
- s0 =
Cattywampus
- s1 =
sCattywampu
Output
- answer =
True
Example 2
Input
- s0 =
Gardyloo
- s1 =
dylooGar
Output
- answer =
True
Explanation
This string is rotated on Gar
and dyloo
Example 3
Input
- s0 =
Taradiddle
- s1 =
diddleTara
Output
- answer =
True
Example 4
Input
- s0 =
Snickersnee
- s1 =
Snickersnee
Output
- answer =
True
Explanation
This one is tricky but it’s still a rotation, between ``andSnickersnee
Leave a comment