Expedi problem test case


one test case is fail plzz help me to figure out my mistake

Hey Pritam!
try this test
4
4 4
5 2
11 7
15 10
25 15
answer should be 1 but your output is 2
this is because you refuel from last station, but you could have refuelled even earlier
where fuel capacity was more. So for this maintain a priority_queue.

1 Like

can we try this question by greedy algorithm

Yes it is a classy greedy one only!
refer page 21 of this