Facebook merge graph nodes

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-07-02Added By Anonymous
Source: Link

Company: Meta
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

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