체육복

호랑·2022년 5월 26일
0

코딩 테스트 공부

목록 보기
1/3

https://programmers.co.kr/learn/courses/30/lessons/42862

def solution(n, lost, reserve):
    answer = 0
    borrow = []
    for a in range(1, n+1):
        if a in lost and a in reserve:
            lost.remove(a)
            reserve.remove(a)
            # print(answer)
    for i in range(1,n+1):
        # print("i", i)
        if i in lost:
            if i-1 in reserve and i-1 not in borrow:
                borrow.append(i-1)
                answer +=1
            elif i+1 in reserve and i+1 not in borrow:
                borrow.append(i+1)
                answer +=1
            # print(answer)
            # print(borrow)
        else:
            answer +=1
            # print(answer)
            # print(borrow)
        
    return answer
profile
데이터리터러시 기획자 / 데이터 분석가가 꿈!

0개의 댓글