🌏 문제
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
👽 풀이
def solution(n, lost, reserve):
lost1 = [x for x in lost if x not in reserve]
reserve1 = [x for x in reserve if x not in lost]
answer = n - len(lost1)
lost1.sort()
reserve1.sort()
for i in lost1:
if i-1 in reserve1:
answer += 1
reserve1.remove(i-1)
continue
if i+1 in reserve1:
answer += 1
reserve1.remove(i+1)
continue
return answer
728x90
'💡코딩테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스 | 파이썬 python] 구명보트 (0) | 2023.04.21 |
---|---|
[프로그래머스 | 파이썬 python] 큰 수 만들기 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 모음사전 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 전력망을 둘로 나누기 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 피로도 (0) | 2023.04.21 |
🌏 문제
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
👽 풀이
def solution(n, lost, reserve):
lost1 = [x for x in lost if x not in reserve]
reserve1 = [x for x in reserve if x not in lost]
answer = n - len(lost1)
lost1.sort()
reserve1.sort()
for i in lost1:
if i-1 in reserve1:
answer += 1
reserve1.remove(i-1)
continue
if i+1 in reserve1:
answer += 1
reserve1.remove(i+1)
continue
return answer
728x90
'💡코딩테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스 | 파이썬 python] 구명보트 (0) | 2023.04.21 |
---|---|
[프로그래머스 | 파이썬 python] 큰 수 만들기 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 모음사전 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 전력망을 둘로 나누기 (0) | 2023.04.21 |
[프로그래머스 | 파이썬 python] 피로도 (0) | 2023.04.21 |