Count Picked Items Less Than Queries
Updated
Problem statement
A warehouse has items given as 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 from index startIndex[i] through endIndex[i], including both ends. Put the values picked by all orders together into one group. If more than one order picks the same item, its value is in the group once for each of those orders.
For each value query[i], return how many picked items in the group have a 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 Online Assessment questions
- Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026
- Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent ElementsOA · PHONE SCREEN · Seen Nov 2026
- Get Smallest Base SegmentOA · Seen Nov 2026
- Minimum Cost of Left and Right PropagationOA · Seen Nov 2026
- Minimum Grid InconvenienceOA · Seen Nov 2026
- Maximize Shipment Order by Sorting One WindowOA · Seen Nov 2026
- Maximum Equal-Bit Pairs in a SubsequenceOA · Seen Nov 2026
- First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
- Two SumOA · PHONE SCREEN · Seen Nov 2026