문제
풀이 과정
const solutionA = (answers) => {
const answer = [];
const A = [1, 2, 3, 4, 5];
const B = [2, 1, 2, 3, 2, 4, 2, 5];
const C = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5];
const count = [0, 0, 0];
for (let i = 0; i < answers.length; i++) {
const right = answers[i];
A[i % A.length] === right && count[0]++;
B[i % B.length] === right && count[1]++;
C[i % C.length] === right && count[2]++;
}
const max = Math.max(...count);
for (let i = 0; i < 3; i++) {
if (max === count[i]) answer.push(i + 1);
}
return answer;
};
const testA = solutionA([1, 3, 2, 4, 2]);
console.log(testA);
틀린 부분이 있거나 보충해야 할 내용이 있다면 댓글이나 DM(sungstonemin)으로 알려주시면 감사하겠습니다😄