all is well!!
32. ๋ก๋์ ์ต๊ณ ์์์ ์ต์ ์์ ๋ณธ๋ฌธ
๐ ๋ฌธ์
๐ ๋ต
function solution(lottos, win_nums) {
var count = [];
var answer = [];
let min=0;
let zero=0;
for(let i=0; i<lottos.length; i++){
for(let j=0; j<lottos.length; j++){
if(lottos[i]==win_nums[j]) min++;
}
if(lottos[i]==0) zero++;
}
count=[min+zero,min]
for(let i=0; i<count.length; i++){
if(count[i]==6) answer.push(1);
else if(count[i]==5) answer.push(2);
else if(count[i]==4) answer.push(3);
else if(count[i]==3) answer.push(4);
else if(count[i]==2) answer.push(5);
else if(count[i]<=1) answer.push(6);
}
return answer;
}
// 1. 0์ด ์๋ ์ซ์๋ค์ด ๋น์ฒจ๋ฒํธ์ ๋ง๋์ง ๋น๊ตํด์ ๊ฐฏ์ ์ถ๋ ฅ
// 2. ์ต๊ณ ์๋ 0์ ์ ๋ถ ๋น์ฒจ๋ฒํธ๊ฐ ์๋ค๊ณ ๊ฐ์ ํ๊ณ ๊ฐฏ์์ ๋ํ๊ธฐ
// 3. ์ต์ ์๋ 0์ ์ ๋ถ ๋น์ฒจ๋ฒํธ๊ฐ ์๋ค๊ณ ๊ฐ์ ํ๊ณ ๊ฐฏ์์ ๋ํ๋๊ฒ ์์
// 4. ์กฐ๊ฑด๋ฌธ์ผ๋ก ๊ฐฏ์๋ฅผ ๋น๊ตํด์ ์ต์ ๋ฑ์ ์ต๊ณ ๋ฑ์ ๊ฐ๋ ค๋ด๊ธฐ
'์๊ณ ๋ฆฌ์ฆ(js)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
34. ๋ฌธ์์ด ๋ด ๋ง์๋๋ก ์ ๋ ฌํ๊ธฐ (0) | 2022.11.17 |
---|---|
33. ๋ชจ์๊ณ ์ฌ (0) | 2022.11.16 |
31. ๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ (0) | 2022.11.14 |
30. ๊ฐ์ ์ซ์๋ ์ซ์ด (0) | 2022.11.13 |
29. ์ต์์ง์ฌ๊ฐํ (0) | 2022.11.12 |
Comments