Search
⌘K
Get Premium
Leetcode 774. Minimize Max Distance to Gas Station
Given positions of existing gas stations and a budget k of new stations to add, place the k stations to minimize the maximum distance between adjacent stations on the line. This is typically solved by binary-searching the minimum possible maximum gap (a real value) and greedily checking whether that gap can be achieved by counting how many new stations each interval needs.
Asked at:
Amazon
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Mid November, 2024
Amazon
Junior
Aggressive Cows (Max Distance): Place k cows in stalls to maximize the minimum distance between any two cows.
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.