반응형
def solution(n, lost, reserve):
reserve_arr = sorted([ data for data in reserve if data not in lost ])
lost_arr = sorted([ data for data in lost if data not in reserve ])
result = n
if len(lost_arr) > 0 or len(reserve_arr) > 0:
for data in reserve_arr:
if data - 1 in lost_arr:
lost_arr.remove(data-1)
continue
if data + 1 in lost_arr:
lost_arr.remove(data+1)
continue
result = result - len(lost_arr)
return result반응형
'삽집하는 개발들 > 알고리즘' 카테고리의 다른 글
| [20일차][프로그래머스][131128]숫자 짝꿍 (0) | 2023.07.10 |
|---|---|
| [19일차][프로그래머스][133499]옹알이(2) (0) | 2023.07.08 |
| [17일차][프로그래머스][42576]완주하지 못한 선수 (0) | 2023.07.04 |
| [17일차][프로그래머스][140108]문자열 나누기 (0) | 2023.07.04 |
| [16일차][프로그래머스][2019 카카오 - 64061]크레인 인형뽑기 게임 (0) | 2023.07.03 |