Skip to content

Instantly share code, notes, and snippets.

@mumunuu
Last active January 25, 2021 05:01
Show Gist options
  • Save mumunuu/9a1d2b9ed7b0d09c97c3e8be91aef646 to your computer and use it in GitHub Desktop.
Save mumunuu/9a1d2b9ed7b0d09c97c3e8be91aef646 to your computer and use it in GitHub Desktop.
algorithm(leetcode) Valid Anagram
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