반응형
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
- Crawling
- 알고리즘
- 크롤링
- HTTP
- HTTP 완벽 가이드
- BFS
- Algorithm
- dp
- Node.js
- ip
- 프로그래머스
- javascript
- 가천대
- 백준
- socket
- typescript
- 타입스크립트
- 수학
- 프로그래머스 레벨 2
- Nestjs
- TCP
- 자바스크립트
- 쉬운 문제
- type challenge
- 그래프
- dfs
- 레벨 1
- 소켓
- 타입 챌린지
- 문자열
Archives
- Today
- Total
kakasoo
[node.js] 로또의 최고 순위와 최저 순위 ( 프로그래머스 레벨1 ) 본문
반응형
// 프로그래머스 레벨1 로또의 최고 순위와 최저 순위를 풀었습니다.
const setRank = (n) => {
switch (n) {
case 6:
return 1;
case 5:
return 2;
case 4:
return 3;
case 3:
return 4;
case 2:
return 5;
case 1:
case 0:
return 6;
}
};
const solution = (lottos, win_nums) => {
const numbers = lottos.filter((el) => el !== 0);
const zeros = lottos.filter((el) => el === 0);
let count = 0;
numbers.forEach((num) => {
if (win_nums.includes(num)) {
count++;
}
});
return [setRank(count + zeros.length), setRank(count)];
};
반응형
'프로그래밍 > 알고리즘 풀이' 카테고리의 다른 글
[node.js] 수식 최대화 ( 프로그래머스 레벨2 ) (0) | 2021.06.30 |
---|---|
[node.js] 신규 아이디 추천 ( 프로그래머스 레벨1 ) (0) | 2021.06.30 |
[node.js] 폰켓몬 ( 프로그래머스 레벨1 ) (0) | 2021.06.30 |
[node.js] 음양 더하기 ( 프로그래머스 레벨1 ) (0) | 2021.06.30 |
[node.js] 약수의 개수와 덧셈 ( 프로그래머스 레벨1 ) (0) | 2021.06.30 |