Allocate limited inventory items based on priority algorithm.
During a flash sale on Amazon, customers submit requests for a limited quantity of a product. Each of the request includes: [customerId, quantity, bidAmount, timestamp].
Items are allocated using these rules:
Return the IDs of customers who received no items.
Note: Round-robin allocation means cycling through the tied customers in order of their timestamps, granting exactly one item to each customer per cycle, until either the inventory runs out or all their requested quantities are fulfilled.
Input:
requests = [[1, 5, 5, 0], [2, 7, 8, 1], [3, 7, 5, 1], [4, 10, 3, 3]]
totalInventory = 18
Output: [4]
Explanation: The first three requests have a higher bidding amount than 4th request, and the total quantity requested in the first three requests is 19, whereas the available inventory is 18, so only one left without any allocation will be customer ID 4.
Complete the function getUnfulfilledCustomers with the following parameters:
int requests[requests[0],...requests[n-1]]: 2D array of integers where each row is [customerId, quantity, bidAmount, timestamp]int totalInventory: an integer, the total number of items available for allocationint[]: a list of customer IDs who did not receive any items, sorted in ascending orderJefeeerirs • Pending
Jefeeerirs • Pending
Jefeeerirs • Pending
Texas • Pending