[Programmers] - 프린터 (Level 2)
스택/큐
LEVEL : 2
문제링크
priorities = [1, 1, 9, 1, 1, 1]
location = 0
def solution(priorities, location):
answer = []
length = len(priorities)
dat = [[priorities[i],i] for i in range(len(priorities))]
while len(answer) < length:
first = max([i[0] for i in dat])
if dat[0][0] < first:
tmp = dat.pop(0)
dat.append(tmp)
else:
tmp = dat.pop(0)
answer.append(tmp)
return answer.index([priorities[location],location])+1
solution(priorities, location)
5
Comments