Skip to content

Instantly share code, notes, and snippets.

@asraraljuhani
Last active June 25, 2021 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asraraljuhani/587a68a0751dcd6bad12fb532d9db84b to your computer and use it in GitHub Desktop.
Save asraraljuhani/587a68a0751dcd6bad12fb532d9db84b to your computer and use it in GitHub Desktop.
def is_permutation(arr1, arr2):
if len(arr1) == 0 or len(arr2) == 0 or len(arr1) != len(arr2):
return False
else:
for i in range(len(arr1)):
if arr1[i] != arr2[len(arr2)-1-i]:
return False
return True
print(is_permutation("toot", "ioot"))
print(is_permutation([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment