Inside Inclusive Range
Programming Basics · Java
TASK
Problem
Print `YES` if `n` is in [1, 11], otherwise print `NO`.
EXAMPLE
Example
1
YES
LIMITS
Constraints
-10^9 ≤ n ≤ 10^9; the checked interval is [1,11]
LEARN
Theory for this problem
+
The core idea of **Inside Inclusive Range** is to model the requested operation directly: Print `YES` if `n` is in [1, 11], otherwise print `NO`. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Inside Inclusive Range** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Inside Inclusive Range
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n >= 1 && n <= 11) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}