큐를 사용해서 조건에 맞게 반복하고, 실행된 횟수를 출력

 

def solution(priorities, location):
    answer = 0
    wait_list = list(zip(priorities, list(i for i in range(len(priorities)))))
    c = 0
    while wait_list !=0:
        ex = wait_list.pop(0)
        if ex[0] == max(priorities):
            c += 1
            priorities.remove(max(priorities))
            if ex[1] == location:
                return c
        else:
            wait_list.append(ex)
    return answer

+ Recent posts