์๊ณ ๋ฆฌ์ฆ(js)
33. ๋ชจ์๊ณ ์ฌ
tnqlscho 95
2022. 11. 16. 23:37
๐ ๋ฌธ์
๐ ๋ต
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 ์ด ๋ถ๋ถ์ด ์ดํด๊ฐ ์ ์๋์๋ค..ใ
์ง์ง ์ํฌ์๋ ๋์ธ๊ฐ๋ดใ ใ ใ