반응형
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 |
Tags
- dfs
- 가천대
- BFS
- typescript
- 소켓
- 타입스크립트
- 쉬운 문제
- HTTP 완벽 가이드
- Node.js
- 수학
- 프로그래머스
- 프로그래머스 레벨 2
- Algorithm
- javascript
- 레벨 1
- HTTP
- TCP
- 그래프
- dp
- 자바스크립트
- 타입 챌린지
- Nestjs
- 문자열
- socket
- 백준
- 알고리즘
- type challenge
- 크롤링
- ip
- Crawling
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 |