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.
Absolutely it is. And further this means, if you are using an adjacency list to find sibling nodes, then looking up some node x and finding y in the adjacency list, means you should also be able to look up node y and find x somewhere in its adjacency list.
E.g.
adjList[x] => [ ?, ?, ?, y, ?, ... ]
Implies:
adjList[y] => [ ?, x, ?, ?, ?, ... ]
But the input data set does not explicity reflect that, so you need to ensure that you map both ways for any given edge. This caused me some debugging to figure out.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Breadth First Search: Shortest Reach
You are viewing a single comment's thread. Return to all comments →
Absolutely it is. And further this means, if you are using an adjacency list to find sibling nodes, then looking up some node x and finding y in the adjacency list, means you should also be able to look up node y and find x somewhere in its adjacency list. E.g.
Implies:
But the input data set does not explicity reflect that, so you need to ensure that you map both ways for any given edge. This caused me some debugging to figure out.