def merge(a: Node | None, b: Node | None) -> Node | None:
The round: five reports, November 2025 to September 2026, in infra and application loops; four of them are onsite coding rounds. One interviewer said it comes from a real LinkedIn problem. A sixth report, an infra phone screen, names only the high-frequency question about merging two trees into one, without details, so it may be this problem. It is LeetCode 617 (Merge Two Binary Trees) moved to N-ary trees: every node has a key, and only nodes with the same key merge. Reported follow-ups: serialize an N-ary tree, and what to do when merges run concurrently. Two graded parts.
The node (given)
class Node:
def __init__(self, key, value=None, children=None): ...
def show(node): ... # (key, value, [children...]) as nested tuples, or None
Part 1 — merge two trees by key
def merge(a: Node | None, b: Node | None) -> Node | None: ...
None, return the other. Otherwise the two roots must have the same key; the merged root has that key.b's value, and its children are merged the same way.a's children in a's order, then b's children whose keys a does not have, in b's order.show.Clarify first. One report says to ask about corner cases such as roots with different keys. Here that raises ValueError (not tested). The value rule (b wins), the child order and returning the other tree when one side is empty are not in the reports either; ask what the interviewer wants.
Notes: the key on every node, merging only equal keys, a DFS solution, the different-roots corner case, the N-ary version of LeetCode 617, the serialize follow-up and the concurrency follow-up are from the reports. One report links an outside page about overwrite rules that we cannot see in the thread. Ours: the names, the show helper, b's value winning, the child order, returning the other tree when one is None, the per-level rule stated above, the key and value types in Part 2, and every test. The concurrency follow-up is discussed under the solution, not graded.
Several reports describe it the same way: every node has a key, only nodes with the same key merge, and DFS solves it. One interviewer said it came from a real LinkedIn problem and then asked what to do about concurrency; the candidate answered MVCC or locking and did not know if that was the expected answer. Another round followed the merge with serializing an N-ary tree. One candidate stresses asking about corner cases first, for example whether the two roots have the same key; that candidate wrote an optimal solution and still failed, and blames a second question in the same round that the interviewer did not follow. An infra phone-screen report that names only the high-frequency question about merging two trees (possibly this one) says that before the coding, the interviewer asked general systems and Java knowledge questions.
What the reports say: LeetCode 617 moved to N-ary trees, where every node has a key and only nodes with the same key merge; DFS solves it. Four of the reports are onsite coding rounds, and one interviewer said it comes from a real LinkedIn problem; a phone-screen report that names only merging two trees may be the same problem. Ask about corner cases first, such as roots with different keys. Follow-ups were concurrency (MVCC or locks was the candidate's answer) and serializing the tree.
Common mistakes (ours, not reported): Pairing children by position; Comparing every pair of children; Dropping b's new children; A serialization without the shape.
Edge cases to test (ours): An empty tree on either side; One key at two depths; Disjoint children; Keys with commas.
Also reported as Merge N-ary Tree · Merge N-Tree · LeetCode 617 Variant
The round: five reports, November 2025 to September 2026, in infra and application loops; four of them are onsite coding rounds. One interviewer said it comes from a real LinkedIn problem. A sixth report, an infra phone screen, names only the high-frequency question about merging two trees into one, without details, so it may be this problem. It is LeetCode 617 (Merge Two Binary Trees) moved to N-ary trees: every node has a key, and only nodes with the same key merge. Reported follow-ups: serialize an N-ary tree, and what to do when merges run concurrently. Two graded parts.
The node (given)
class Node:
def __init__(self, key, value=None, children=None): ...
def show(node): ... # (key, value, [children...]) as nested tuples, or None
Part 1 — merge two trees by key
def merge(a: Node | None, b: Node | None) -> Node | None: ...
None, return the other. Otherwise the two roots must have the same key; the merged root has that key.b's value, and its children are merged the same way.a's children in a's order, then b's children whose keys a does not have, in b's order.show.Part 2 — serialize the tree
def serialize(root: Node | None) -> str: ...
def deserialize(data: str) -> Node | None: ...
deserialize(serialize(t)) must rebuild the same keys, values, child order and shape. The format is yours.None. An empty tree round-trips to None.Clarify first. One report says to ask about corner cases such as roots with different keys. Here that raises ValueError (not tested). The value rule (b wins), the child order and returning the other tree when one side is empty are not in the reports either; ask what the interviewer wants.
Notes: the key on every node, merging only equal keys, a DFS solution, the different-roots corner case, the N-ary version of LeetCode 617, the serialize follow-up and the concurrency follow-up are from the reports. One report links an outside page about overwrite rules that we cannot see in the thread. Ours: the names, the show helper, b's value winning, the child order, returning the other tree when one is None, the per-level rule stated above, the key and value types in Part 2, and every test. The concurrency follow-up is discussed under the solution, not graded.
What happens when merges run concurrently?
Serialize an N-ary tree.
Ask about corner cases first, such as two roots with different keys.
What the reports say: LeetCode 617 moved to N-ary trees, where every node has a key and only nodes with the same key merge; DFS solves it. Four of the reports are onsite coding rounds, and one interviewer said it comes from a real LinkedIn problem; a phone-screen report that names only merging two trees may be the same problem. Ask about corner cases first, such as roots with different keys. Follow-ups were concurrency (MVCC or locks was the candidate's answer) and serializing the tree.
Common mistakes (ours, not reported): Pairing children by position; Comparing every pair of children; Dropping b's new children; A serialization without the shape.
Edge cases to test (ours): An empty tree on either side; One key at two depths; Disjoint children; Keys with commas.
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 90 LinkedIn questions, refreshed monthly from new candidate reports.