프린터 - python (programmers)

참치돌고래·2021년 5월 18일
0

알고리즘

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

스택/큐 level2

프린터

-->https://programmers.co.kr/learn/courses/30/lessons/42587

from collections import deque

def solution(priorities, location):
    answer = 1
    queue= deque()
    
    for priority in priorities:
        queue.append([priority,0])
    queue[location][1] = 1
    print(queue)
    
    while queue:
        priority,loc = queue.popleft()
        if priority >= max(priorities):
            if loc == 1:
                return answer
            elif loc == 0:
                answer +=1
                priorities.remove(max(priorities))
                
        else:
            queue.append([priority,loc])
            
    
    return answer
profile
안녕하세요
post-custom-banner

0개의 댓글