+1 vote
in Python by
Given two strings A and B, return whether or not A can be shifted some number of times to get B.

1 Answer

0 votes
by

Example:

A = 'abcde'

B = 'cdeab'

can_shift(A, B) == True

A = 'abc'

B = 'acb'

can_shift(A, B) == False

This problem is relatively simple if we work out the underlying algorithm that allows us to easily check for string shifts between the strings A and B. First off, we have to set baseline conditions for string shifting. Strings A and B must both be the same length and consist of the same letters. We can check for the former by setting a condition statement when the length of A and B are equivalent.

...