Simple, Fast Python Solution


  • 0
    M
    class Solution(object):
        def findTheDifference(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: str
            """
            d = dict()
            for l in s:
                d[l] = d.get(l, 0) + 1
                
            for l in t:
                d[l] = d.get(l, 0) - 1
            
            return filter(lambda x: d[x] != 0, d.keys())[0]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.