suggest an algorithm for the following puzzle!!

Posted by garima on Stack Overflow See other posts from Stack Overflow or by garima
Published on 2011-02-22T04:35:14Z Indexed on 2011/02/22 7:25 UTC
Read the original article Hit count: 138

There are n petrol bunks arranged in circle. Each bunk is separated from the rest by a certain distance. You choose some mode of travel which needs 1litre of petrol to cover 1km distance. You can't infinitely draw any amount of petrol from each bunk as each bunk has some limited petrol only. But you know that the sum of litres of petrol in all the bunks is equal to the distance to be covered.

ie let P1, P2, ... Pn be n bunks arranged circularly. d1 is distance between p1 and p2, d2 is distance between p2 and p3. dn is distance between pn and p1.Now find out the bunk from where the travel can be started such that your mode of travel never runs out of fuel.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about interview-questions