Created
August 21, 2017 03:48
-
-
Save luojiyin1987/e3d4005cd8f7a4f792d0867b737908bd to your computer and use it in GitHub Desktop.
Valid Anagram
This file contains hidden or 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 { | |
| 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