更新后的减去更新前的即为新添加的
class Solution(object):
def findTheDifference(self, s, t):
"""
:type s: str
:type t: str
:rtype: str
"""
hasp_map={}
for i in range(len(t)):
if hasp_map.get(t[i]) is not None:
hasp_map[t[i]]+=1
else:
hasp_map[t[i]]=1
for i in range(len(s)):
hasp_map[s[i]]-=1
if hasp_map[s[i]]==0:
del hasp_map[s[i]]
return hasp_map.keys()[0]