Hey, I just found a problem on spoj EXPEDI — Expedition https://www.spoj.com/problems/EXPEDI/ which is a greedy problem and I came to know that the problem can be solved by using heap(max) data structure. But I was unable to figure out how this problem can be solved using heap. I am new to programming so, please help me with some explanation how to approach this problem with heap. I am eager to learn. Thanks a lot in advance.

I think that you start from source and as you are going towards destination, keep track of all the stations in between. As soon as you see that you don't have fuel then greedily, we can take the max fuel and move forward.

Thanks.