def solution(n, lost, reserve):
answer = 0
total = list()
for i in range(n):
total.append(1)
for i in lost:
total[i-1] -= 1
for i in reserve:
total[i-1] += 1
for i in range(len(total)):
if total[i] == 2:
if i-1 >= 0:
if total[i-1] == 0:
total[i-1] += 1
total[i] -= 1
if total[i] == 2:
if i+1 < len(total):
if total[i+1] == 0:
total[i+1] += 1
total[i] -= 1
for student in total:
if student >= 1:
answer += 1
return answer
'Coding Test > Programmers_Python' 카테고리의 다른 글
[프로그래머스/python] 숫자의 표현 (0) | 2020.07.28 |
---|---|
[프로그래머스/] 피보나치 수 (0) | 2020.07.28 |
[프로그래머스/python] 2016년 (0) | 2020.07.21 |
[프로그래머스/python] 정수 내림차순으로 배치하기 (0) | 2020.07.16 |
[프로그래머스/python] 자릿수 더하기 (0) | 2020.07.14 |