최대 1 분 소요

Python

import collections
def solution(priorities, location):
    answer = 0
    q: deque = collections.deque([(v, i) for i, v in enumerate(priorities)])
    
    while q:
        temp = q.popleft()
        if q and temp[0] < max(q)[0]:
            q.append(temp)
        else:
            answer += 1
            if temp[1] == location:
                return answer

댓글남기기