단속 카메라 - python(programmers)

참치돌고래·2021년 8월 30일
0

알고리즘

목록 보기
12/36
post-custom-banner

https://programmers.co.kr/learn/courses/30/lessons/42884

def solution(routes):
    answer = 1
    
    
    routes.sort(key = lambda x:x[0])
    print(routes)
    standardx = routes[0][0]
    standardy = routes[0][1]
    for i in range(1,len(routes)):
        start=routes[i][0]
        end = routes[i][1]
        print(start, end)
        if (end<=standardy) & (standardx<=start):
            standardx = start
            standardy = end
            
        elif (end>standardy) & (standardx<=start<=standardy):
            
            standardx = start
            
        else:
            standardx = start
            standardy = end
            answer+=1
            
        
        
        
        
    return answer
profile
안녕하세요
post-custom-banner

0개의 댓글