Skip to main content
All Questions

Allocate inventory to customer bids by bid amount, using round-robin on ties.

Unlock detailed company stats for this questionUpgrade

You are managing an inventory system at Amazon. You receive N bids from customers in the format [customerId, bidAmount, quantity, bidPlacedAt].

Allocate inventory to customers with these rules:

  • Customers with a higher bid amount get priority.
  • If multiple customers have the same bid amount, allocate inventory round-robin among them (1 item per customer per cycle) until inventory runs out or their bid is fully satisfied.

Return the list of customer IDs whose bids are not fully fulfilled.

Example 1: bids = [[1,3,1,1],[2,4,2,2]], totalInventory = 1 output: [1] Customer 2 has the higher bid amount, so gets priority and takes the only unit; customer 1's bid goes unfulfilled.

Example 2: bids = [[1,3,2,1],[2,3,2,2],[3,3,1,3]], totalInventory = 4 output: [] All customers bid the same amount, so inventory is allocated round-robin: cycle 1 gives 1 unit each to customers 1, 2 and 3 (3 units used, 1 remaining). Cycle 2 gives the last unit to customer 1, who still needs more and is next in order. Final allocation: customer 1 gets 2, customer 2 gets 2, customer 3 gets 1.

Format · 40-minute OA coding question.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.