Maximize the Weakest Zone's Coverage After Adding K Delivery Stations
Last updated: November 29, 2026
Quick Overview
Zones lie on a line, and zone i already has stations[i] delivery stations. A station covers every zone within distance r. You may add k new stations anywhere. Return the largest possible minimum coverage over all zones.
Amazon
November 29, 20260
0
0 solved
Zones lie on a line, and zone i already has stations[i] delivery stations. A station covers every zone within distance r. You may add k new stations anywhere. Return the largest possible minimum coverage over all zones.
A Hard Amazon onsite problem that combines binary search on the answer with a greedy sweep and a difference array. It mirrors network planning for delivery stations, where leaders want the least-served zone to be as well served as possible.
What the Interviewer Expects
- Compute initial coverage with a prefix sum over the window [i - r, i + r]
- Binary search on the target minimum coverage
- Greedily add stations as far right as possible (at i + r) when a zone falls short
- Use a difference array so each added station's effect expires after its window
- Analyze O(n log(sum + k))
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why is placing the new station at i + r optimal?
- What if each new station had a different cost by zone?
- How would you handle a 2D grid of zones?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: list stations of n non-negative integers, radius r >= 0, k >= 0. Coverage of zone i is the total stations in zones [i - r, i + r] clipped to the array. Output: maximum achievable min coverage ...
High-Level Design
First compute base coverage with prefix sums. For a target T, sweep left to right. Keep a running sum of extra stations currently affecting zone i using a difference array. If base[i] + extra < T, add...