programmers | Lv1. 완주하지 못한 선수

yeonk·2022년 2월 22일
0

algorithm

목록 보기
36/88
post-thumbnail

💡 Python 3






🔗 문제

완주하지 못한 선수 [Link]






💻 코드

애먹었던 문제.. 파이썬 스터디 할 때 알게된 Counter를 쓰고 싶어서 시간을 많이 투자했다. 풀어서 뿌듯하다 !!!

def solution(p, c):
    from collections import Counter
    counter = Counter(p) - Counter(c)
    return list(counter.keys())[0]






💥 다른 사람 코드

def solution(participant, completion):
    participant.sort()
    completion.sort()
    for i in range(len(completion)):
        if participant[i] != completion[i]:
            return participant[i]
    return participant[len(participant)-1]

0개의 댓글