Google Question | Can anyone come up with a C++ Code for this?
Anonymous User
804

You are given a list of cities connected with each other. Find the minimum number of days to start from city A to reach city B. Note that it takes 1 day to travel from one city to another that is directly connected i.e. the weight of each branch is 1.
**I have done the above, I need help with the following follow up part of the question: **

You are now given a maximum fuel capacity F. You start from a city source with F litre of fuel. Fuel stations are available only in specific cities. You can refill the tank to the full capacity with no extra time. Now find the minimum number of days.

For eg.
Source = A
Destination = E
Fuel Capacity = 3
Station = [M]
A - B - C - D - E
|
M
Output: 6
Source = A
Destination = F
Fuel Capacity = 3
Station = [K]
H J K
\ | /
A - B - C - D - E - F
|
M
Output: -1

Comments (5)