Your question is Rotation Check Using strstr. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In Pocket Gems' Episode, a compact string may represent an ordered sequence of story-state tokens. Given two strings s1 and s2, determine whether s2 is a rotation of s1, meaning it can be produced by moving some prefix of s1 to its end without changing the character order.
Your solution must use at most one substring-search operation, equivalent to one call to C's strstr. Do not search for every possible rotation individually.
Implement is_rotation(s1, s2).
s1 and s2 containing arbitrary characters.True if s2 is a rotation of s1; otherwise, return False.def is_rotation(s1, s2):