def solution(n, lost, reserve):
a = [1] * n
for i in lost:
a[i - 1] -= 1
for i in reserve:
a[i - 1] += 1
for i in range(n):
if a[i] == 0:
if i > 0 and a[i - 1] == 2:
a[i - 1] -= 1
a[i] += 1
elif i < n - 1 and a[i + 1] == 2:
a[i + 1] -= 1
a[i] += 1
else:
continue
return n - a.count(0)
처음에 테스트코드의 답은 계속 맞았으나 실패가 자꾸 떴다. 나중에 if문에서 인덱스를 저렇게 수정하고 나니 통과하였다.