python use Counter


  • 0
    V
    class Solution(object):
        def findTheDifference(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: str
            """
            from collections import Counter
            s = Counter(s)
            t = Counter(t)
            for k in t:
                if s[k] != t[k]:
                    return k
    

Log in to reply
 

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