Skip to content

Latest commit

 

History

History
18 lines (18 loc) · 329 Bytes

242有效的字母异位词.md

File metadata and controls

18 lines (18 loc) · 329 Bytes
func isAnagram(s string, t string) bool {
    if len(s) != len(t) {
        return false
    }
    table := make(map[byte]int)
    for i := 0; i < len(s); i++ {
        table[s[i]]++
        table[t[i]]--
    }
    for _, n := range table {
        if n != 0 {
            return false
        }
    }
    return true
}