- 0of 0 votes
Given a list of n gas station of form P(D,X) where D is the distance from this station to next station and X is the amount of petrol available at this station, identify the starting station from where you can complete journey to each station in order from 1.....N. You can only go in one direction i.e from P(i) to P(i+1)- ravigupt in India
EDIT: I forgot to mention that travelling distance K consumes K units of gas.
EDIT2: I proposed an O(n^2) solution, then interviewer asked me if I can do better.
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm