给定两个字符串s和t,都只包含小写字母。字符串t由字符串s打乱顺序并且额外在随机位置添加一个字母组成。寻找t中新增的那个字母。
keys()以列表形式返回一个字典所有的键 , pop()用于移除列表中的某个元素(默认最后一个),并返回该值
class Solution(object):
def findTheDifference(self, s, t):
"""
:type s: str
:type t: str
:rtype: str
"""
ds = collections.Counter(s)
dt = collections.Counter(t)
return (dt-ds).keys().pop()