LeetCode Problem "871. Minimum Number of Refueling Stops".
https://leetcode.com/problems/minimum...
A car travels from a starting position to a destination which is target miles east of the starting position.
Along the way, there are gas stations. Each station[i] represents a gas station that is station[i][0] miles east of the starting position, and has station[i][1] liters of gas.
The car starts with an infinite tank of gas, which initially has startFuel liters of fuel in it. It uses 1 liter of gas per 1 mile that it drives.
When the car reaches a gas station, it may stop and refuel, transferring all the gas from the station into the car.
What is the least number of refueling stops the car must make in order to reach its destination? If it cannot reach the destination, return -1.
Note that if the car reaches a gas station with 0 fuel left, the car can still refuel there. If the car reaches the destination with 0 fuel left, it is still considered to have arrived.
---------------------------------------------------------------
Join our 30-days online course to prepare for coding interviews of companies like Google, Amazon, Facebook, Microsoft, etc.
Course On Coding: http://www.ritambhara.in/big-o/
Course On System Design: http://www.ritambhara.in/system-desig...
We have our office in Greater Noida (India) where we run courses for students to prepare them for placements in Top IT companies. For Placement Preparation and Industrial Training call us.
Call: +91-8377803450
Email: [email protected]
Call us to conduct a workshop in your college campus.
Buy our books and prepare for coding interviews on your own.
https://www.amazon.in/Kamal-Rawat/e/B...
For detailed discussions on Interview Questions visit:
http://www.ritambhara.in/