[ INFO ]category: Coding difficulty: medium freq: 1 first seen: 2026-04-27
[MEDIUM][CODING][1]Hash MapStringGraph
$catproblem.md
You are given a list of message parts that were cut from a single original message. Reconstruct the original message by joining the parts in the correct order.
Rules:
The original message starts with the character A and ends with the character Z.
Two parts can be joined when the last character of one part equals the first character of the next part.
When joining two parts, the shared boundary character appears only once in the result. Example: "A--b" + "b--z" -> "A--b--z" (not "A--bb--z").
The first character of every part is unique among all parts.
A unique reconstruction is guaranteed.
Examples:
`
parts = ["b--Z", "A--b"]
result = "A--b--Z"
parts = ["A-x", "x-y", "y-Z"]
result = "A-x-y-Z"
`
Follow-up Questions:
What if the parts could be joined in multiple valid ways? How would you detect the ambiguity?
What if the dataset was streamed instead of given up-front?