• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
May 23, 2024 |770 Views

PROBLEM OF THE DAY : 22/05/2024 | Minimize Max Distance to Gas Station

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Binary Search but also build up problem-solving skills.

In this problem, we are given a horizontal number line. On that number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where n = size of the stations array. Now, we add k more gas stations so that d, the maximum distance between adjacent gas stations, is minimized. We have to find the smallest possible value of d. Find the answer exactly to 2 decimal places.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/minimize-max-distance-to-gas-station/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp14-compiler/5071125f-6cbc-4ef0-98f9-fe9e91200ea4