题目
On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.
Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.
Return the smallest possible value of D.
Example:
Input: stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9
Output: 0.500000
Note:stations.length will be an integer in range [10, 2000].
stations[i] will be an integer in range [0, 10^8].
K will be an integer in range [1, 10^6].
Answers within 10^-6 of the true value will be accepted as correct.翻译:
假设我们在一条水平数轴上,列表 stations 来表示各个加油站的位置,加油站分别在 stations[0], stations[1], ..., stations[N-1] 的位置上,其中 N = stations.length。
现在我们希望增加 K 个新的加油站,使得相邻两个加油站的距离 D 尽可能的最小,请你返回 D 可能的最小值。
示例:
输入&#x
最低0.47元/天 解锁文章
573

被折叠的 条评论
为什么被折叠?



