문제
길이가 서로 다른 A, B, C 세 개의 막대 길이가 주어지는 경우
삼각형을 만들 수 있으면 'YES' 만들 수 없다면 'NO'를 출력
풀이 과정 a
const solutionA = (...rest) => {
let sum = 0;
const maxLength = Math.max(...rest);
for (let i = 0; i < rest.length; i++) {
if (maxLength > rest[i]) sum += rest[i];
}
return maxLength < sum ? 'YES' : 'NO';
};
풀이 과정 b
const solutionB = (A, B, C) => {
const totalSum = A + B + C;
const maxLength = Math.max(A, B, C);
const otherLength = totalSum - maxLength;
return maxLength < otherLength ? 'YES' : 'NO';
};
틀린 부분이 있거나 보충해야 할 내용이 있다면 댓글이나 DM(sungstonemin)으로 알려주시면 감사하겠습니다😄