Skip to main content
All Questions

Maximize the logs held by the k/2 secure warehouses after distributing delivery logs.

Unlock detailed company stats for this questionUpgrade

You are given an array delivery_logs representing the number of logs in each delivery unit and an integer k representing the total number of warehouses. Each warehouse can only store logs from a single delivery unit (logs from different deliveries cannot mix). There are k/2 secure warehouses. Return the maximum number of secure logs possible. (40 minutes)

Example 1: Input: delivery_logs = [3,5,9,6], k = 4 Output: 9 Explanation: Take 5 logs from the 3rd delivery into warehouse 1, all 6 logs from the 4th delivery into warehouse 2, the remaining 4 logs from the 3rd delivery into warehouse 3, and all logs from the 2nd delivery into warehouse 4. Warehouses become [5,6,4,5]. The secure warehouses (k/2 = 2) are the two largest: 5 and 4, which sum to 9.

Example 2: Input: delivery_logs = [5,5,5,5,5,5], k = 4 Output: 10 Explanation: Pick any 4 deliveries and place 5 logs each in 4 warehouses. Warehouses become [5,5,5,5]. Any two secure warehouses sum to 10.

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.