275. How Many Fall in the Range
Given n integers and two bounds lo and hi, print how many values
satisfy lo <= value <= hi. Both bounds are inclusive.
Counting by scanning is O(n) and perfectly fine for one question. Sorting
first costs O(n log n) once and then answers this in O(log n), which is
the arrangement you want when many ranges are asked about the same data.
Both endpoints are lower bounds, which is why that one search keeps earning its place.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ lo ≤ hi ≤ 1000000000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains three integers n, lo and hi.
The second line contains n integers.
Output
Print one integer, the count of values within the inclusive range.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.