가장 높으면 출력하면서 answer += 1
없으면 맨 뒤로 보낸다.
deque를 이용하여 popleft사용해서 빼고 append로 넣기
from collections import deque
def solution(priorities, location):
answer = 1
p = deque(priorities)
while p:
m = max(p)
if location == 0:
if p[0] >= m:
return answer
else:
p.append(p.popleft())
elif p[0] >= m:
p.popleft()
answer += 1
else:
p.append(p.popleft())
if location - 1 < 0:
location = len(p) - 1
else:
location -= 1
return answer