Can we shift string A to string B?

This Question Was Asked By Google

Given two strings A and B, return whether or not string A can be shifted some number of times to get B. A shift operation is described as moving the characters of a string forward or backwards without changing the order of characters in the string. i.e given string xyz, if we shift it once, we get zyx (z shifted right and hence moved to first position, so it shifted x which was first position, to second position and hence y got moved to third position from second position, giving us zyx).

Write a function solve which accepts the following parameter(s):
1.) A = a string
2.) B = a string

Example
Input:
A = abcde
B = cdeab
Output:
True

Explanation
• Example 1: string A abcde, string B cdeab
• Shift it right once, we get eabcd
• Shift it right again, we get deabc
• Shift it right again, we get cdeab which is same as target string B cdeab. Hence we return True.

Example Input:
A = abc
B = acb
Output:
False

Explanation • Example 2: string abc, string B acb
• Shift it right once, we get cab
• Shift it right again, we get bca
• Shift it right again, we get abc which is the original string that we started with, which means we cannot convert it to target string B acb. Hence we return False.

Constraints
• The length of the string A will be greater than 0 and less than 1000.
• The length of the string B will be greater than 0 and less than 1000.