🧠𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺/💙프로그래머스
[코딩테스트 고득점 Kit / Level2 🧒🏻 / 스택/큐] 프린터(python)
안오늘
2021. 7. 8. 07:52
1. 문제 설명
https://programmers.co.kr/learn/courses/30/lessons/42587
2. 나의 풀이
from collections import deque
def solution(priorities, location):
answer = 0
queue = deque()
for i in range(len(priorities)):
queue.append((priorities[i], i))
while len(queue) > 0:
data = queue.popleft()
if len(queue) != 0:
maxData = max(queue)
if data[0] < maxData[0]:
queue.append(data)
else:
answer += 1
if data[1] == location:
break
else:
answer += 1
if data[1] == location:
break
return answer