문제 출처
풀이
def solution(routes):
answer = []
routes.sort(key=lambda x: (x[0], x[1]))
_, move_out = routes[0]
for i in range(1, len(routes)):
if routes[i][0] > move_out:
answer.append(i)
_, move_out = routes[i]
else:
move_out = min(routes[i][1], move_out)
if answer[-1] != len(routes):
return len(answer)+1
return len(answer)
'Programmers' 카테고리의 다른 글
[python] 섬 연결하기 (0) | 2019.10.14 |
---|---|
[python] 등굣길 (0) | 2019.10.14 |
[python] 이중우선순위큐 (0) | 2019.10.14 |
[python] 디스크 컨트롤러 (0) | 2019.10.13 |
[python] 문자열 압축 (0) | 2019.10.06 |