PROBLEM 37
Easy

Number Outside Range

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#37

Given `n`, `left`, `right`, print `YES` if `n` is outside `[left, right]`, else `NO`.

EXAMPLE

Example

Input
3 5 10
Output
YES

LIMITS

Constraints

left ≤ right
📖
LEARN Theory for this problem
+

### Number Outside Range

`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.', 'Order the checks so a more specific case is not swallowed by a broader condition.']

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