Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created August 21, 2017 03:48
Show Gist options
  • Save luojiyin1987/e3d4005cd8f7a4f792d0867b737908bd to your computer and use it in GitHub Desktop.
Save luojiyin1987/e3d4005cd8f7a4f792d0867b737908bd to your computer and use it in GitHub Desktop.
Valid Anagram
func isAnagram(s string, t string) bool {
if len(s) != len(t) {
return false
}
if len(s) ==0 && len(t) ==0 {
return true
}
temp1 := make(map[int32]int)
for _,v := range s {
temp1[v]++
}
for _, v := range t {
temp1[v]--
}
for _, v:= range temp1 {
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