Skip to content

Commit beefb2d

Browse files
committed
완전탐색
1 parent b78714c commit beefb2d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const list = [
2+
[1, 2, 3, 4, 5],
3+
[2, 1, 2, 3, 2, 4, 2, 5],
4+
[3, 3, 1, 1, 2, 2, 4, 4, 5, 5],
5+
];
6+
7+
function solution(answers) {
8+
const result = [0, 0, 0];
9+
answers.forEach((a, i) => {
10+
list.forEach((l, j) => {
11+
if (a === l[i % l.length]) result[j] += 1;
12+
});
13+
});
14+
15+
const max = Math.max(...result);
16+
return result.reduce((acc, cur, i) => {
17+
if (cur === max) return [...acc, i + 1];
18+
return acc;
19+
}, []);
20+
}

0 commit comments

Comments
 (0)