Learn
Exam

Check If Number Is in Range

Difficulty
STARTER

Problem

Given an integer number, a starting value start, and an ending value end, write a function solution that checks if number is within the range from start to end inclusive.


Constraints

  • number, start, and end are integers between -100 and 100 inclusive.
  • start is less than or equal to end.
  • If number is within the range, return the string "YES"; if it is outside the range, return the string "NO".

Test Case

Test Case Number number start end return
1 5 1 10 "YES"
2 -1 -10 -1 "YES"
3 7 8 20 "NO"

Explanation for Test Case 1

  • When number = 5, start = 1, and end = 10, 5 is within the range from 1 to 10, so return "YES".

Explanation for Test Case 2

  • When number = -1, start = -10, and end = -1, -1 is within the range from -10 to -1, so return "YES".

Explanation for Test Case 3

  • When number = 7, start = 8, and end = 20, 7 is not within the range from 8 to 20, so return "NO".