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.