Need help from Python Coders

Hello coders, I really want your help to code this problem in python using heapq or priority queue.

Link: https://www.geeksforgeeks.org/minimize-cost-to-reach-end-of-an-n-length-straight-path/

I have tried my best, following code if you want to debug it, the problem is the output isn’t minized cost and seems that I failed to convert the java code into python.

Code:

using priority q library: priorityQuest - Pastebin.com
using heapq library: heapqQues - Pastebin.com

The output for this should be 40, but I m getting 48.

Please help me debug this, I’d really appreciate it, thank you.

The code is not formatted correctly, and that is why it won’t run locally in my machine. If possible can you share the code via some code-sharing websites like pastebin or ideone?

1 Like

I’m so sorry for the trouble you went through because of me, here’s code:

using priority q library: priorityQuest - Pastebin.com
using heapq library: heapqQues - Pastebin.com

Thank you!