You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: real_interview_questions/Google/Minimize_road_between_stations.md
+34-7Lines changed: 34 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,47 @@
1
+
# QUESTION
2
+
There is long motorway of length M (an integer).
3
+
On the motorway at some points (integers) there are petrol stations (there is a given integer array T[] of length N - the positions of petrol stations).
4
+
We have funds to add at most K new petrol stations on this motorway.
5
+
We want to minimize largest stretch of the motorway between petrol stations.
6
+
You can put petrol stations on integer positions.
7
+
8
+
1. Design and implement a function that calculates the minimum achievable uncovered motorway length.
9
+
2. Write testcases for your algorithm.
10
+
3. (Bonus) Analyze your algorithm's runtime and space complexity.
11
+
4. (Bonus) Suggest optimizations of your algorithm.
12
+
5. (Bonus) Modify the function from part 1 to output positions at which the new stations can be added to
13
+
achieve the optimum uncovered motorwary length.
14
+
15
+
Example:
16
+
N = 5, M = 20, K = 3, T = [3, 7, 15, 18, 1]
17
+
Minimum uncovered : 3 (obtainable for example by adding petrol stations at positions: 5, 10 and 13)
0 commit comments