Facebook merge graph nodes

Anonymous User
4550
Jul 02, 2020
Jul 03, 2020
Given a directed graph such as:
A -> B -> C -> D
merge it into one node ABCD.

second example:
A ->        -> D
     B -> C 
E ->        -> F
after merge:
A ->    -> D
     BC
E ->    -> F

I felt the interviewer's wording of the problem was intentionally vague so you have to figure out what the merge condition is.
Comments (16)