Created
May 11, 2024 02:50
-
-
Save samocodes/dd770c8e0a40b061e32cfa795c015b78 to your computer and use it in GitHub Desktop.
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
func isAnagram(s string, t string) bool { | |
char := make([]int, 26) | |
for _, v := range s { | |
i := int(v - 'a') | |
char[i]++ | |
} | |
for _, v := range t { | |
i := int(v - 'a') | |
char[i]-- | |
} | |
for _, v := range char { | |
if v != 0 { | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution 2