Given three bars of different lengths (A, B, C), “YES” is output if these three bars can form a triangle, and “NO” if they cannot be made.
The first line gives you 100 different lengths of bars A, B, and C.
6, 7, 11
13, 33, 17
Print “YES” and “NO” on the first line.
YES
NO
if
function solution(a, b, c) {
let answer = 'yes',
max;
let sum = a + b + c;
if (a > b) max = a;
else max = b;
if (c > max) max = c;
if (sum - max < max) answer = 'no';
return answer;
}
sort()
function solution(a, b, c) {
let arr = [a, b, c];
let answer = 'yes';
arr.sort((a, b) => a - b);
if (arr[0] + arr[1] <= arr[2]) answer = 'no';
return answer;
}
Math.min()
function solution(a, b, c) {
let answer = 'yes';
let sum = a + b + c;
let max = Math.max(a, b, c);
if (sum - max <= max) answer = 'no';
return answer;
}