PROBLEM 62
Medium

Triangle Existence

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#62

Given positive sides `a`, `b`, `c`, print `YES` if a triangle can exist, else `NO`.

EXAMPLE

Example

Input
3 4 5
Output
YES

LIMITS

Constraints

a > 0; b > 0; c > 0
📖
LEARN Theory for this problem
+

### Triangle Existence

`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.

💡
NEED HELP? Hints
+

['Translate every case from the statement into a boolean condition before writing branches.', 'Mentally substitute at least one value for each branch and verify that exactly the intended branch runs.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [a, b, c] = input.trim().split(/\s+/).filter(Boolean).map(Number);
if (((a + b) > c) && ((a + c) > b) && ((b + c) > a)) {
    console.log("YES");
} else {
    console.log("NO");
}