https://school.programmers.co.kr/learn/courses/30/lessons/42587
def solution(priorities, location):
answer = 0
# idx_list만들기
idx_list =[]
for idx in range(len(priorities)):
idx_list.append(idx)
priorities_copy = priorities.copy()
idx = 0
while idx < len(priorities)-1:
if priorities_copy[idx] < max(priorities_copy[idx+1:]):
idx_list.append(idx_list.pop(idx))
priorities_copy.append(priorities_copy.pop(idx))
else:
idx+=1
answer = idx_list.index(location)+1
return answer
solution(priorities, location)
def solution(priorities, location):
answer = 0
queue = [[i, p] for i, p in enumerate(priorities)]
max_prioty = max(priorities)
while True:
cur = queue.pop(0)
# 값이 가장 클 때
if cur[1] == max_prioty:
answer += 1
# max값 재설정
priorities.remove(max_prioty)
if len(priorities) != 0:
max_prioty = max(priorities)
# location 확인
if cur[0] == location:
return answer
# 큰 값이 아닐 때
else:
queue.append(cur)
priorities = [1, 1, 9, 1, 1, 1]
queue = [[i, p] for i, p in enumerate(priorities)]
# [[0, 1], [1, 1], [2, 9], [3, 1], [4, 1], [5, 1]]