all is well!!
33. ๋ชจ์๊ณ ์ฌ ๋ณธ๋ฌธ
๐ ๋ฌธ์

๐ ๋ต
function solution(answers) {
var answer = [];
let supoja1 = [1,2,3,4,5]
let supoja2 = [2,1,2,3,2,4,2,5]
let supoja3 = [3,3,1,1,2,2,4,4,5,5]
let count = []
let one = answers.filter((v,i)=>v==supoja1[i%supoja1.length]).length;
let two = answers.filter((v,i)=>v==supoja2[i%supoja2.length]).length;
let thr = answers.filter((v,i)=>v==supoja3[i%supoja3.length]).length;
count.push(one,two,thr);
for(let i=0; i<count.length; i++){
if(Math.max(...count)==count[i]) answer.push(i+1)
}
return answer;
}
answers.filter((v,i)=>v==supoja1[i%supoja1.length]).length;
์ ๊ธฐ์ i%supoja1.length ์ด ๋ถ๋ถ์ด ์ดํด๊ฐ ์ ์๋์๋ค..ใ
์ง์ง ์ํฌ์๋ ๋์ธ๊ฐ๋ดใ ใ ใ
'์๊ณ ๋ฆฌ์ฆ(js)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| 35. ๋ฌธ์์ด ๋ด๋ฆผ์ฐจ์์ผ๋ก ๋ฐฐ์นํ๊ธฐ (0) | 2023.05.05 |
|---|---|
| 34. ๋ฌธ์์ด ๋ด ๋ง์๋๋ก ์ ๋ ฌํ๊ธฐ (0) | 2022.11.17 |
| 32. ๋ก๋์ ์ต๊ณ ์์์ ์ต์ ์์ (0) | 2022.11.15 |
| 31. ๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ (0) | 2022.11.14 |
| 30. ๊ฐ์ ์ซ์๋ ์ซ์ด (0) | 2022.11.13 |
Comments