nearHundred

Easy · Basic Logic · 7 test cases

Given an int n, return true if it is within 10 of 100 (i.e., 90 <= n <= 110) or within 10 of 200 (i.e., 190 <= n <= 210).

Examples

nearHundred(93) → true
nearHundred(90) → true
nearHundred(89) → false
nearHundred(191) → true

Starter code

function nearHundred(n) {

}

Complexity of the optimal solution

Time O(1), space O(1). The solution involves a few subtractions, absolute value calculations, and comparisons. These are all constant time operations.

Solve nearHundred in the browser