[20251105] PGM / LV2 / 프로세스 / 강신지 #1325
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/42587
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
큐에 대기 중인 프로세스를 우선순위 순으로 실행할 때, 특정 프로세스가 몇 번째에 실행되는지 구하는 문제.
🔍 풀이 방법
우선순위가 남아있는 개수를 세어 둔 배열을 사용해, 현재 실행해야 할 최대 우선순위를 빠르게 찾는다. 큐에서 하나씩 꺼내며 최고 우선순위면 실행, 아니면 다시 큐에 넣는 방식으로 시뮬레이션
⏳ 회고
우선순위 탐색을 매번 선형으로 하면 비효율적이므로 카운팅을 활용하는 게 깔끔