Skip to content

Commit

Permalink
solve(programmers): LV2_42587_프로세스_py
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumaC committed Apr 22, 2024
1 parent b048a60 commit 280c706
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/programmers/level_1/자료구조/LV2_프로세스.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 10:06~10:47
from collections import deque


def solution(priorities, location):
q = deque([(v, i) for i, v in enumerate(priorities)])
s = sorted([(-v, v) for _, v in enumerate(priorities)])

idx = 0
while True:
cur = q.popleft()
if s[idx][1] == cur[0]:
idx += 1
if cur[1] == location: return idx
else:
q.append(cur)

0 comments on commit 280c706

Please sign in to comment.