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