반응형
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
- Nestjs
- dfs
- 소켓
- dp
- ip
- socket
- 그래프
- 크롤링
- 문자열
- 프로그래머스 레벨 2
- 레벨 1
- 자바스크립트
- HTTP 완벽 가이드
- Crawling
- 쉬운 문제
- 타입 챌린지
- Node.js
- Algorithm
- type challenge
- TCP
- 수학
- javascript
- typescript
- 타입스크립트
- HTTP
- 가천대
- 알고리즘
- BFS
- 백준
- 프로그래머스
Archives
- Today
- Total
kakasoo
[node.js] 프린터 ( 프로그래머스 레벨2 ) 본문
반응형
// 프로그래머스 레벨2 프린터를 풀었습니다.
const 더큰게있니 = (얘, 다른애들) => {
for (let i = 0; i < 다른애들.length; i++) {
if (다른애들[i].prio > 얘.prio) return true;
}
return false;
};
function solution(priorities, location) {
let index = [];
priorities.map((el, i) => {
index.push({ idx: i, prio: el });
});
console.log(index);
let count = 0;
while (index.length !== 0) {
let temp = index.shift();
if (더큰게있니(temp, index)) {
index.push(temp);
} else {
count++;
if (temp.idx === location) return count;
}
}
}
예전에 풀어서 함수 명을 왜 저렇게 했는지 기억이 안난다.
반응형
'프로그래밍 > 알고리즘 풀이' 카테고리의 다른 글
[node.js] 124나라 ( 프로그래머스 레벨2 ) (0) | 2021.06.28 |
---|---|
[node.js] 다리를 지나는 트럭 ( 프로그래머스 레벨2 ) (0) | 2021.06.28 |
[node.js] 스킬트리 ( 프로그래머스 레벨2 ) (0) | 2021.06.28 |
[node.js] [1차]다트 게임 ( 프로그래머스 레벨1 ) (0) | 2021.06.28 |
[node.js] [1차]비밀지도 ( 프로그래머스 레벨1 ) (0) | 2021.06.28 |