Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- 99클럽
- 엘리스sw트랙
- node.js
- 데이터베이스시스템
- 파이썬
- JavaScript
- 꿀단집
- 파이썬프로그래밍기초
- 중간이들
- SQL
- aws
- 코드잇
- 방송대
- 자격증
- MySQL
- 코딩테스트준비
- Git
- Python
- HTML
- 유노코딩
- Cookie
- 항해99
- redis
- 프로그래머스
- CSS
- 방송대컴퓨터과학과
- nestjs
- 개발자취업
- 코딩테스트
- TiL
Archives
- Today
- Total
배꼽파지 않도록 잘 개발해요
99클럽 코테 스터디 28일차 TIL - 프로세스 본문
function solution(priorities, location) {
// 큐를 우선순위와 인덱스를 포함하는 배열로 반환
let queue = priorities.map((priority, idx) => ({ priority, idx }));
console.log(queue)
// [
// { priority: 2, idx: 0 },
// { priority: 1, idx: 1 },
// { priority: 3, idx: 2 },
// { priority: 2, idx: 3 }
// ]
let printOrder = 0; // 몇 번째로 실행되는지 카운트
while (queue.length > 0) {
let current = queue.shift();
// 현재 프로세스보다 높은 우선순위의 프로세스가 있는지 확인
if (queue.some(process => process.priority > current.priority)) {
queue.push(current)
} else {
printOrder++;
if (current.idx === location) {
return printOrder;
}
}
}
}
728x90
'코딩테스트 > 99클럽' 카테고리의 다른 글
99클럽 코테 스터디 29일차 TIL - Arranging Coins (0) | 2024.08.21 |
---|---|
99클럽 코테 스터디 29일차 TIL - Missing Number (0) | 2024.08.20 |
99클럽 코테 스터디 27일차 TIL - 공원 산책 (0) | 2024.08.17 |
99클럽 코테 스터디 26일차 TIL - 바탕화면 정리 (0) | 2024.08.17 |
99클럽 코테 스터디 25일차 TIL - Find if Path Exists in Graph [BFS] (0) | 2024.08.15 |