Problem
Count Picked Items Less Than Queries
Learn this problemProblem statement
A warehouse has items represented by an array items, where items[i] is the value of the i-th item.
There are several orders. The i-th order picks every item in the inclusive index range startIndex[i] through endIndex[i]. Across all orders, this creates one combined multiset of picked item values.
For each value query[i], return how many picked items have value strictly less than query[i].
Function
countPickedItemsLessThan(items: int[], startIndex: int[], endIndex: int[], query: int[]) → int[]Examples
Example 1
items = [1,2,5,4,5]startIndex = [0,0,1]endIndex = [1,2,2]query = [2,4]return = [2,5]The orders pick values [1,2], [1,2,5], and [2,5]. Two picked values are less than 2, and five are less than 4.
Constraints
1 <= items.lengthstartIndex.length == endIndex.length0 <= startIndex[i] <= endIndex[i] < items.length
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026