본문 바로가기
Programmers

[python] 완주하지 못한 선수

by DylanMsK 2019. 9. 3.

문제 출처

완주하지 못한 선수

 

풀이


def solution(participant, completion):
    answer = ''
    dict_participant = {}
    for name in completion:
        if dict_participant.get(name, None):
            dict_participant[name] += 1
        else:
            dict_participant[name] = 1
    for name in participant:
        if dict_participant.get(name, None):
            if dict_participant[name]:
                dict_participant[name] -= 1
            else:
                answer = name
                break
        else:
            answer = name
            break
    return answer
    

'Programmers' 카테고리의 다른 글

[python] 위장  (0) 2019.09.06
[python] 전화번호 목록  (0) 2019.09.03
[python] 추석 트래픽  (0) 2019.09.03
[python] 무지의 먹방 라이브  (0) 2019.09.03
[python] 단어 변환  (0) 2019.09.01