import collections class Solution(object): def findTheDifference(self, s, t): sc = collections.Counter(s) tc = collections.Counter(t) '''subtraction of 2 dictionaries, returns the diff dictionary. list(dict) returns a list of only the keys, same as list(dict.keys()). get the 0th element of that list and return it''' return list(tc-sc)
Simple python solution
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.