Last active
January 25, 2021 05:01
-
-
Save mumunuu/9a1d2b9ed7b0d09c97c3e8be91aef646 to your computer and use it in GitHub Desktop.
algorithm(leetcode) Valid 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
func isAnagram(s string, t string) bool { | |
//배열의 길이가 다르면 false | |
if len(s) != len(t) { | |
return false | |
} | |
for _, r := range s { | |
val := string(r) //현재 값 | |
//서로 들어있는 갯수가 다르면 애너그램이 될 수 없음 | |
if strings.Count(s, val) != strings.Count(t, val) { | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment