Created
November 21, 2023 05:26
-
-
Save Ayoush/ab3a90412b742fd57fb54de54e232c33 to your computer and use it in GitHub Desktop.
anagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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