문제
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
문제 풀이
단순 구현 문제
코드
from collections import deque
def solution(priorities, location):
answer = 0
priorities = deque(priorities)
while priorities:
now_printing = priorities.popleft()
location -= 1
print(now_printing,location)
if len(priorities) > 0 and max(priorities) > now_printing:
priorities.append(now_printing)
if location == -1:
location = len(priorities)-1
else:
answer += 1
if location == -1: #현재 뽑아놓음
return answer
'알고리즘 > 프로그래머스' 카테고리의 다른 글
n^2배열 자르기 (Python) (0) | 2023.01.17 |
---|---|
[1차] 캐시 (Python) (0) | 2023.01.16 |
H-Index (Python) (0) | 2023.01.16 |
멀리 뛰기 (Python) (0) | 2023.01.16 |
점프와 순간이동 (Python) (0) | 2023.01.16 |