Code Room
CodingMediumcod-g787
Subject Linked listsLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A multilevel doubly linked list is given as a nested structure: a list of nodes where each node is [val, child] and child is either null (encoded as None / empty) — represented here as another nested list of the same shape, or [] for no child. Flatten it depth-first so a node's child sublist is spliced in right after that node and before the rest of the level. Return the flattened list of values in order.

Implement
flatten_multilevel(nodes: list) → list[int]
Examples
in[[[1,[]],[2,[[3,[]],[4,[]]]],[5,[]]]]out[1,2,3,4,5]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.