luoheng
10/12/2019 - 6:34 AM

isAnagram

func isAnagram(s string, t string) bool {
    c := [26]int{}
    for i := 0; i < len(s); i++ {
        c[s[i]-'a']++
    }
    for i := 0; i < len(t); i++ {
        c[t[i]-'a']--
    }
    for i := 0; i < len(c); i++ {
        if c[i] != 0 {
            return false
        }
    }
    return true
}