Skip to content

Instantly share code, notes, and snippets.

@MichaelSDavid
Created August 20, 2020 20:52
Show Gist options
  • Save MichaelSDavid/8da8040bbdd40d81dbba595aa89e743b to your computer and use it in GitHub Desktop.
Save MichaelSDavid/8da8040bbdd40d81dbba595aa89e743b to your computer and use it in GitHub Desktop.
Daily Interview Pro example solution for shifted string problem on 08/20/2020
def is_shifted(a, b):
shift_list = []
def shift(n, s):
tmp = [char for char in s]
shift_str = ''.join(tmp[-n:] + tmp[:-n])
return shift_str
for i in range(1, len(a)):
shift_list.append(shift(i, a))
if b in shift_list:
return True
else:
return False
print(is_shifted('abcde', 'cdeab')) # True
print(is_shifted('abc', 'acb')) # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment