컴공생의 다이어리
[프로그래머스] 프린터 - 파이썬(Python) 본문
[프로그래머스] 프린터 - 파이썬(Python)
def solution(priorities, location):
priorities = [(v, idx) for idx, v in enumerate(priorities)]
count = 0
while True:
if priorities[0][0] == max(priorities)[0]:
count += 1
if priorities[0][1] == location:
break
priorities.pop(0)
else:
priorities.append(priorities.pop(0))
return count
https://programmers.co.kr/learn/courses/30/lessons/42587
코딩테스트 연습 - 프린터
일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린
programmers.co.kr
728x90
'Development > Algorithm & Coding Test' 카테고리의 다른 글
[프로그래머스] 주식가격 - 파이썬(Python) (0) | 2022.05.11 |
---|---|
[프로그래머스] 다리를 지나는 트럭 - 파이썬(Python) (0) | 2022.05.10 |
[프로그래머스] 기능개발 - 파이썬(Python) (0) | 2022.05.08 |
[프로그래머스] 베스트앨범 - 파이썬(Python) (0) | 2022.05.07 |
[프로그래머스] 위장 - 파이썬(Python) (0) | 2022.05.06 |
Comments