Dijkstra? help required

problem link : Dijkstra
my solution

Why am i getting memorty limit exceeded??

Try this case :

4 3
2 3
3 4
2 4

You will get an infinite loop here :


And you will exceed the memory limit of your vector “path”.

However, even if you fixed that , I think you would still get TLE because you have O(n^2) complexity.

I recommend using this implementation

1 Like