I’ve been trying to implement Dijkstra’s algo, but i’m getting an MLE in test case 31.
Here’s my code : My Submission
Here’s the problem statement : C - Dijkstra?
Can you please help me with this? How can I resolve this MLE issue??
Am I getting the MLE because of the HashMap? Will some other data structure work?
I don’t know how you do it in java, but try changing INTEGER.MAX to something which is bigger ( Of order 1e18 ). That should be the fix.
1 Like
You were right buddy! Thanks a lot.
I changed it to Long.MAX_VALUE and got AC
Accepted Code
But why was Integer.MAX_VALUE giving me MLE and why did Long.MAX_VALUE work? Can you please explain?
I got wrong answer verdict for same reason, I can explain what went wrong for my c++ code, but for your case it says memory limit error and the only difference between your and mine code is of language. So my best educated guess would be that maybe java handles over flows differently than c++.
1 Like
oh ok. But if ‘integer overflow’ is the problem then shouldn’t it give a RE or a WA verdict? instead of MLE?
Anyways, thanks a lot for your help!
1 Like
ohhhh okay! Thanks for the explanation.