728x90
[μκ° μ½λ μ±λ¦°μ§ μμ¦ 1]
λ κ° λ½μμ λνκΈ°
My μ½λ
function solution(numbers) {
var answer = [];
for(let i=0;i<numbers.length;i++) {
for(let j=i+1;j<numbers.length;j++) {
let sum = numbers[i] + numbers[j];
if(answer.includes(sum) == false) {
answer.push(sum);
}
}
}
answer.sort((a, b) => a - b);
return answer;
}
λ€λ₯Έ μ¬λμ νμ΄
function solution(numbers) {
const temp = []
for (let i = 0; i < numbers.length; i++) {
for (let j = i + 1; j < numbers.length; j++) {
temp.push(numbers[i] + numbers[j])
}
}
const answer = [...new Set(temp)]
return answer.sort((a, b) => a - b)
}
728x90
λκΈ