Haribo ML, AI, MATH, Algorithm

체육복

2021-01-16
Haribo

체육복

코드

def solution(n, lost, reserve):
    reserve_new = set(reserve) - set(lost)
    lost_new = set(lost) - set(reserve)
    for r in reserve_new:
        front = r - 1
        back = r + 1
        if front in lost_new:
            lost_new.remove(front)
        elif back in lost_new:
            lost_new.remove(back)
    return n - len(lost_new)

Similar Posts

이전 포스트 완주하지 못한 선수

Comments