Skip to content

Instantly share code, notes, and snippets.

@Ayoush
Created November 21, 2023 05:26
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 Ayoush/ab3a90412b742fd57fb54de54e232c33 to your computer and use it in GitHub Desktop.
Save Ayoush/ab3a90412b742fd57fb54de54e232c33 to your computer and use it in GitHub Desktop.
anagram
def isAnagram(s, t):
if len(s) != len(t):
return False
s_hash = []
t_hash = []
for i in range(0, len(s)):
if s[i] in t_hash:
t_hash.remove(s[i])
else:
s_hash = s_hash + [s[i]]
if t[i] in s_hash:
s_hash.remove(t[i])
else:
t_hash = t_hash + [t[i]]
if s_hash == t_hash == [] :
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment