Amazon SDE I INTERN OA Experience Question Discussion
Summary
I completed an online assessment that asked me to maximize the number of secure deliveries across k warehouses.
Full Experience
Had this question in an Amazon OA.
Question
You are given:
deliveryLogs[] — number of deliveries in each log k — an even number representing the number of warehouses
You have exactly k warehouses.
A warehouse can contain deliveries from only one log. Deliveries from the same log can be split across multiple warehouses. After storing everything, the largest k/2 warehouses are compromised. Only the deliveries in the remaining k/2 warehouses are considered secure.
Find the maximum possible number of secure deliveries.
Interview Questions (1)
Maximum Secure Deliveries
You are given an array deliveryLogs[] where each element represents the number of deliveries in a log, and an even integer k representing the total number of warehouses. You must allocate the deliveries to exactly k warehouses with the following constraints:
- Each warehouse can contain deliveries from only one log.
- Deliveries from the same log can be split across multiple warehouses.
- After allocation, the largest
k/2warehouses are considered compromised. - Only the deliveries stored in the remaining
k/2warehouses are counted as secure.
Return the maximum possible number of secure deliveries.