내가짠코드
def solution(priorities, location):
    mx = max(priorities)
    cnt = 1
    while True:
        if priorities[0] < mx:
            temp = priorities.pop(0)
            priorities.append(temp)
            location -= 1
            #print("P", priorities, "L", location)
        elif priorities[0] == mx:
            if location == 0 or len(priorities) == abs(location):
                #print("P", priorities, "L", location)
                break
            priorities.pop(0)
            priorities.append(0)
            location -=1
            cnt += 1
            mx = max(priorities)
            #print("P", priorities, "L", location)
            
    #print(cnt)
    return cnt
잘짠코드
def solution(priorities, location):
    answer = 0
    search, cursor = sorted(priorities, reverse=True), 0
    
    while True:
        for idx, priority in enumerate(priorities):
            s = search[cursor] # max value
            if priority == s: # if the priority value equals max value
                cursor += 1 # move current cursor to the right
                answer += 1 # print the max
                if idx == location:
                    break
        else:
            continue
        break
    return answer
풀이 이해를 위한 출력
idx 0 priority 1 cursor 0 s 9 answer 0
idx 1 priority 1 cursor 0 s 9 answer 0
idx 2 priority 9 cursor 0 s 9 answer 0
idx 3 priority 1 cursor 1 s 1 answer 1
idx 4 priority 1 cursor 2 s 1 answer 2
idx 5 priority 1 cursor 3 s 1 answer 3
idx 0 priority 1 cursor 4 s 1 answer 4
직후에 cursor, answer += 1 하고 break
답 : 5
좋아요 제일 많이 받은 코드
from collections import deque
def solution(priorities, location):
    queue =  deque([(i,p) for i,p in enumerate(priorities)])
    answer = 0
    while True:
        cur = queue.popleft()
        if any(cur[1] < q[1] for q in queue):
            queue.append(cur)
        else:
            answer += 1
            if cur[0] == location:
                return answer
풀이