Python solution ( beat 88 % )


  • 1
    R
    class Solution(object):
      def findTheDifference(self, s, t):
          hashtable = dict.fromkeys(set(s),0)
          for i in list(s):
             hashtable[i] += 1
          for j in list(t):
             if not hashtable.get(j) or hashtable[j] == 0:
                 return(j)
             else:
                 hashtable[j] -= 1
    
    

Log in to reply
 

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