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
'algorithm > python' 카테고리의 다른 글
카카오블라인드/2020/가사검색 (0) | 2020.07.27 |
---|---|
프로그래머스/DFS,BFS/타겟 넘버 (0) | 2020.03.18 |
hackerrank/Stacks and Queues/Balanced Brackets (0) | 2020.03.09 |
hackerrank/Hash Tables/Ransom Note (0) | 2020.03.09 |
hackerrank/String/Sherlock and the Valid String (0) | 2020.03.08 |