algorithm/python
프로그래머스/탐욕법/체육복
아르르르를를르
2020. 3. 16. 00:29
https://programmers.co.kr/learn/courses/30/lessons/42862
level1
def solution(n, lost, reserve):
answer = 0
for i in range(1, n+1):
if i in lost and i in reserve:
lost.remove(i)
reserve.remove(i)
for i in range(1, n+1):
if i not in lost:
answer += 1
else:
if i in reserve:
answer +=1
reserve.remove(i)
continue
elif i-1 in reserve:
answer += 1
reserve.remove(i-1)
continue
elif i+1 in reserve:
answer += 1
reserve.remove(i+1)
continue
return answer