Python 프로그래머스 해시 1. 완주하지 못한 선수

def solution(participant, completion):
    answer = ''
    dict= {}
    for p in participant:
        dict[p] = dict.get(p,0) +1
    for c in completion:
        dict[c]-=1
    
    for k,v in dict.items():
        if v!=0:
            answer+=k
            
    return answer



No comments:

Powered by Blogger.