Β
Β
νμ΄λ³΄κΈ°
μΌκ³±λμ₯μ΄μΈλ° 9λͺ
μ΄ μλ€. 2λͺ
μ΄ μ€λ²λλκΉ 2λͺ
μ© κΊΌλ΄κ³ λ λ€μ μ‘°μ¬νλ€.
7λͺ
μ 골λΌμ ν νμ μμ΄ 2λͺ
μ© μ μΈμν€κ³ 7λͺ
μ ν©μ reduce λ©μλλ₯Ό μ΄μ©ν΄ κ³μ°ν΄ νμλ€.
function answer(dwarf) {
let result = [];
for (let i = 0; i < dwarf.length; i++) {
for (let j = 0; j < dwarf.length; j++) {
let tmp = dwarf
.filter((v, idx) => i !== idx && j !== idx);
if (tmp.reduce((cur, acc) => cur + acc) === 100) {
result = tmp;
}
}
}
return result;
}