We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I really need a hint on how to fix my algorithm(I can only pass 3 test cases, the rest timeout) it works but I have to loop over the entire (multidimensional)array every time i get to a new node. should I store each vertex pair with atleast 1 corresponding vertex in an array and put those in an array?
I suppose I could order the vertex pairs so the vertex with the lowest number goes first and then sort it, allowing easier lookups, am I on the right track here?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dijkstra: Shortest Reach 2
You are viewing a single comment's thread. Return to all comments →
I really need a hint on how to fix my algorithm(I can only pass 3 test cases, the rest timeout) it works but I have to loop over the entire (multidimensional)array every time i get to a new node. should I store each vertex pair with atleast 1 corresponding vertex in an array and put those in an array?
I suppose I could order the vertex pairs so the vertex with the lowest number goes first and then sort it, allowing easier lookups, am I on the right track here?