# 389. Find the Difference

`Input: s = "abcd", t = "abcde"Output: "e"Explanation: 'e' is the letter that was added.`
`Input: s = "", t = "y"Output: "y"`
`class Solution:    def findTheDifference(self, s: str, t: str) -> str:        dict_=dict()        for i in s:            if i in dict_:                dict_[i]+=1            else:                dict_[i]=1                        for i in t:            if(i not in dict_ or dict_[i]==0):                return i            else:                dict_[i]-=1`
`class Solution:    def findTheDifference(self, s: str, t: str) -> str:        s=sorted(s)        t=sorted(t)        for i in range(len(s)):            if s[i]!=t[i]:                return t[i]        return t[-1]`
`class Solution:    def findTheDifference(self, s: str, t: str) -> str:        tot=0        for i in range(len(t)):            tot+=ord(t[i])            if(i<len(s)):                tot-=ord(s[i])        return(chr(tot))      #time =O(len(t))    #space = O(1)`
`class Solution:    def findTheDifference(self, s: str, t: str) -> str:        xor_=0        for i in range(len(s)):            xor_^=ord(s[i])^ord(t[i])        return(chr(xor_^ord(t[-1])))`

--

--