FastPrepCount Picked Items Less Than Queries
Problems/Count Picked Items Less Than Queries

Count Picked Items Less Than Queries

Amazon logoAmazonFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

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.length
  • startIndex.length == endIndex.length
  • 0 <= 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

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int[] countPickedItemsLessThan(int[] items, int[] startIndex, int[] endIndex, int[] query) {
      // write your code here
    }
}
Checking account…