STUDY/Algorithm

[프로그래머스] LEVEL2 프린터, python3, 스택/큐

sinawi95 2019. 10. 28. 10:14
728x90

def solution(priorities, location):
    answer = 0
    while priorities!=[]:
        max_pr=max(priorities)
        ind_zr=priorities.pop(0)
        if max_pr==ind_zr:
            answer+=1
            if location==0:
                break
            else:
                location -=1
        else:
            priorities.append(ind_zr)
            if location==0:
                location=len(priorities)-1
            else:
                location-=1
    return answer