You are given a sorted array stations[] representing the positions of existing gas stations on a number line, and an integer k representing the number of additional gas stations you can add. Your task is to add exactly k new gas stations anywhere on the number line such that the maximum distance between any two adjacent gas stations is minimized. Return the minimized maximum distance.
Example 1
Input: stations = [1,2,3,4,5], k = 4
Output: 0.5
Explanation: By adding gas stations between each pair, the distances can be reduced. The maximum distance between adjacent stations becomes 0.5, which is the minimum possible.
Example 2
Input: stations = [1,10], k = 1
Output: 4.5
Explanation: Add one gas station at position 5.5. The distances become 4.5 and 4.5. The maximum distance is minimized to 4.5.
Example 3
Input: stations = [1,5,10], k = 2
Output: 2.5
Explanation: Add gas stations at positions 3 and 7.5. The distances become 2, 2.5, and 2.5. The maximum distance is 2.5, which is minimized.
Sign in to write, run, and submit your solution against the full test suite.