make the full circular path, shortest path exercise?

后端 未结 8 1542
耶瑟儿~
耶瑟儿~ 2021-02-04 22:27

I got this question in an interview and I was not able to solve it.

You have a circular road, with N number of gas stations. You know the ammount of gas

8条回答
  •  不思量自难忘°
    2021-02-04 23:10

    This perhaps?

    • Find the gas station with the largest amount of gas
    • List all gas stations, and take their fuel value, subtract the cost of driving there
    • Drive to the gas station with the highest value
    • Repeat until all gas stations are visited

提交回复
热议问题