Re:The Programming Interview from Hell
by s_tim on Monday February 20, 2017 @10:23AM
(#13687980)
You build from the different tuples in your list just one graph. Then it's just a simple DFS/BFS with one random start node. Which gives you your first component. Then you can get the second if you start at a node which is not in the previous component until you visited all nodes. This should all be in O(n).
[ Parent
| on HN ]
There are no comments on this comment yet.