Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
gk101
on Feb 20, 2017
|
parent
|
context
|
favorite
| on:
The Programming Interview from Hell
[(1, 2, 3), (2, 4, 5)] would result in a graph like this:
1 - 2 - 3
\ 4 - 5
Building the (undirected) graph would take linear time, and once it is built, you can do a simple Depth First Search to mark all the connected components.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
1 - 2 - 3
Building the (undirected) graph would take linear time, and once it is built, you can do a simple Depth First Search to mark all the connected components.