Skip to content

Commit

Permalink
Merge pull request #151 from AlgoLeadMe/1-H0ngJu
Browse files Browse the repository at this point in the history
1-H0ngJu
  • Loading branch information
H0ngJu authored Mar 7, 2024
2 parents 7e66693 + e06b723 commit 512b3bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
@@ -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 | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/169199">๋ฆฌ์ฝ”์ณ‡ ๋กœ๋ด‡</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/1 |
---
20 changes: 20 additions & 0 deletions H0ngJu/ํ/process.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 512b3bf

Please sign in to comment.