I’m applying greedy strategy on the price to minimize the effective cost of travel but getting WA every time, could you please explain what’s wrong in my approach to the problem.
Unable to figure out problem in my code
@satyendra4030 you dont need to calculaute prefix sum for amount of petrol required,simply buy minimum cost petrol at every check point.
i have updated your code a little look at this https://ide.codingblocks.com/s/224933
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.