luoheng
10/11/2019 - 2:09 PM

findTheDifference

func findTheDifference(s string, t string) byte {
    v := [26]int{}
    for i := 0; i < len(s); i++ {
        v[s[i]-'a']++
    }
    var res byte
    for i := 0; i < len(t); i++ {
        v[t[i]-'a']--
        if v[t[i]-'a'] < 0 {
            res = t[i]
            break
        }
    }
    return res
}