Get Smaller Items
An Amazon fulfillment center receives a large number of orders each day. Each order is associated with a range of prices of items that need to be picked from the warehouse and packed into a box. There are n items in the warehouse, which are represented as an array items[n]. The value of items[i] represents the value of ith item in the warehouse, and subsequently there are m orders. The start_index and end_index for the order are represented in the arrays start[i] and end[i]. Also start[i] and end[i] are 0-index based. For each order, all the items are picked from the inclusive range from start[i] through end[i].
Given array items, start, end, and query. For each query[i], find the count of elements in the range with a value strictly less than query[i].
Complete the function getSmallerItems in the editor below.
getSmallerItems has the following parameters:
int items[n]: the value of each itemint start[m]: the start index for each orderint end[m]: the end index for each orderint query[q]: query values
Returns
long output[q]: the answer for each query, the number of picked items having a value strictly less than query.
π³ Manyyy thanks to the GG of Error-Free Excellence π β¨ spike β¨! π
1Example 1

Over the 3 orders, the picked items are [1, 2], [1, 2, 5], and [2, 5].
For the first query, 2 picked items have values less than 2.
5 picked items have values less than 4.
Hence the answer is [2, 5].
2Example 2
Constraints
Limits and guarantees your solution can rely on.
- 1 β€ n β€ 10^5
- 1 β€ items[i] β€ 10^9, where 0 β€ i < n
- 0 < m β€ 10^5
- 0 β€ start[i] β€ end[i] < n, where 0 β€ i < m
- 1 β€ q β€ 10^5
- 1 β€ query[i] β€ 10^9, where 0 β€ i < q