diff --git a/H0ngJu/README.md b/H0ngJu/README.md index d01c5315..af4ff40e 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -1,6 +1,7 @@ -## ✏️ 기록 +## ✏️ 기록 + +| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | +| :---: | :--------: | :------: | :-------------------------------------------------------------------------: | :-------------------------------------------------: | +| 1차시 | 2024.03.05 | 큐 | [프로세스](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/151 | -| 차시 | 날짜 | 문제유형 | 링크 | 풀이 | -|:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2024.03.04 | BFS | 리코쳇 로봇 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/1 | --- diff --git "a/H0ngJu/\355\201\220/process.py" "b/H0ngJu/\355\201\220/process.py" new file mode 100644 index 00000000..b966f0a5 --- /dev/null +++ "b/H0ngJu/\355\201\220/process.py" @@ -0,0 +1,20 @@ +from collections import deque + +def solution(priorities, location): + answer = 0 + queue = deque([(i, k) for k, i in enumerate(priorities)]) # 튜플 큐 생성 + priorities.sort(reverse=True) # 내림차순 정렬 + + while queue: + cur = queue.popleft() # 가장 앞의 프로세스 꺼내기 (queue.pop(0)) + if cur[0] == priorities[0]: # 내림차순으로 정렬된 우선순위 == 현재 순위 -> 가장 높음 + answer += 1 # 수 ++ + if cur[1] == location: # 찾고자하는 process인 경우 + break + priorities.pop(0) + else: + queue.append(cur) # 뒤로 미루기 + + return answer + +#test \ No newline at end of file