title: "[프로그래머스] 체육복 Python 파이썬 해설 (Level 1) - 이도훈"
cleanUrl: "programmers/42862"
description: "프로그래머스 Level 1 문제 [체육복]의 풀이를 정리합니다."
def solution(n, lost, reserve):
lost.sort()
reserve.sort()
answer = n - len(lost)
common = set(lost) & set(reserve)
answer += len(common)
lost = [x for x in lost if x not in common]
reserve = [x for x in reserve if x not in common]
for x in lost:
if x-1 in reserve:
reserve.remove(x-1)
answer += 1
elif x+1 in reserve:
reserve.remove(x+1)
answer += 1
return answer
프로그래머스 코딩테스트 연습 https://school.programmers.co.kr/learn/challenges