Lock in full 90-day FAANG roadmap access before Jan 14, 2026.
⌘K
Minimize Max Distance to Gas Station - Hard DSA Problem | Thita.ai
Minimize Max Distance to Gas Station
Difficulty: Hard
Category: DSA
Topics: Array, Binary Search
Asked at: Google
You are given a **sorted** array `stations` of length `n`, where `stations[i]` represents the position of the `i`th gas station along a number line. You are also given an integer `k`, representing the number of additional gas stations you may add at any position along the number line.
Your task is to add exactly `k` new gas stations such that the **maximum distance** between any two adjacent gas stations is **minimized**.
Return the _minimum possible value_ of the maximum distance between adjacent gas stations after adding the `k` new stations. The answer should be returned as a floating point number with an absolute error less than `1e-6`.