문제 링크
나의 CODE
from collections import defaultdict
def solution(participant, completion):
hash = defaultdict(int)
for i in participant:
hash[i] += 1
for i in completion:
if i in hash:
hash[i] -= 1
for key in hash:
if hash[key] >= 1:
return key
Best CODE
import collections
def solution(participant, completion):
answer = collections.Counter(participant) - collections.Counter(completion)
return list(answer.keys())[0]
Counter
from collections import Counter
Counter(list)
Counter(['a','a','b']) + Counter(['a','b','b'])