Search
⌘K

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

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid November, 2024

Amazon

Amazon

Junior

Aggressive Cows (Max Distance): Place k cows in stalls to maximize the minimum distance between any two cows.

Comments

Your account is free and you can post anonymously if you choose.