Reported March 2026
Bloomberglinked list

Flatten a Multilevel Doubly Linked List

Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Bloomberg OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Bloomberg question, reported in March 2026, is losing the parent's original next pointer the moment you splice the child list in. It's a multilevel doubly linked list flatten, but the twist is that nodes come as index arrays and you return a matrix of [value, prev, next] positions. Preorder order, children before the original successor, one clean list at the end. If you've seen LeetCode's flatten problem, this is the same idea in disguise. If you blank on the splice logic during the OA, StealthCoder sits invisibly on your screen as a safety net.

The problem

A multilevel doubly linked list contains n indexed nodes. Node i stores values[i], may point to its same-level successor through nextIndices[i], and may point to the head of a child doubly linked list through childIndices[i]. A pointer value of -1 means that pointer is absent. Previous pointers are implied by each same-level next chain.
Flatten the structure in preorder: visit a node, then its complete child list, then resume at the node's original next successor. Every child pointer becomes absent, and the flattened nodes form one valid doubly linked list.
Return one row for each flattened position. Row p is [value, previousPosition, nextPosition]. Use -1 for a missing previous or next position. For an empty input, return an empty matrix.

Function
flattenMultilevelList(values: int[], nextIndices: int[], childIndices: int[], headIndex: int) → int[][]

Examples
Example 1
values = [1,2,3,4,5,6,7,8,9,10,11,12]
nextIndices = [1,2,3,4,5,-1,7,8,9,-1,11,-1]
childIndices = [-1,-1,6,-1,-1,-1,-1,10,-1,-1,-1,-1]
headIndex = 0
return = [[1,-1,1],[2,0,2],[3,1,3],[7,2,4],[8,3,5],[11,4,6],[12,5,7],[9,6,8],[10,7,9],[4,8,10],[5,9,11],[6,10,-1]]
The child chain beginning with value 7 is inserted after value 3. Its nested child chain 11, 12 is inserted after value 8 before traversal resumes at 9 and later at 4.
Example 2
values = [1,2,3]
nextIndices = [1,-1,-1]
childIndices = [2,-1,-1]
headIndex = 0
return = [[1,-1,1],[3,0,2],[2,1,-1]]
The child node with value 3 appears immediately after its parent and before the parent's original successor with value 2.
Example 3
values = []
nextIndices = []
childIndices = []
headIndex = -1
return = []
An empty multilevel list has no flattened nodes.

Constraints
0 <= n <= 1000.
values.length = nextIndices.length = childIndices.length = n.
Every pointer is -1 or a valid node index.
If n = 0, then headIndex = -1; otherwise headIndex is valid.
The reachable nodes form an acyclic multilevel doubly linked structure, and every reachable node appears exactly once.
1 <= values[i] <= 10^5.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is preorder traversal. Visit a node, then fully walk its child chain, then resume at the saved next. Two clean ways to do it. Recursive DFS from headIndex that appends each node to an output order list, going child first and then next. Or an explicit stack: pop a node, append it, push next, then push child so child pops first. Either way, save next before you touch the child. Once you have the visit order, positions are just indexes in that list. Row p is [value, p-1 or -1, p+1 or -1 if last]. You don't need to rewire pointers at all. The pitfalls are the empty input with headIndex = -1, forgetting that nested children must finish before resuming, and recursion depth near 1000 nodes. An iterative stack avoids that. If the splice logic slips under pressure, StealthCoder is the hedge during the live OA.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Flatten a Multilevel Doubly Linked List cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as flatten a multilevel doubly linked list. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Bloomberg's OA.

Bloomberg reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Flatten a Multilevel Doubly Linked List FAQ

What's the trick to the Bloomberg flatten multilevel list problem?+

Treat it as a preorder traversal. Visit a node, finish its entire child chain, then go back to the node's original next. The mistake is overwriting next before you save it. A stack where you push next first and child second handles it cleanly.

Do I actually need to rewire the doubly linked pointers?+

No. The output is a matrix, so you only need the visit order. Build a list of node indexes in preorder, then row p is [value, p-1, p+1] with -1 at the ends. That skips pointer surgery and the bugs that come with it.

How hard is this really for an OA?+

Medium. The idea is short once you see preorder, but the index-array input and matrix output add small ways to slip. Edge cases are the empty list and deeply nested children. With n up to 1000, an O(n) traversal is plenty.

Recursion or iterative stack?+

Both work. Recursion is shorter to write. An explicit stack avoids depth worries if the child nesting goes deep. Push next first, then child, so child gets popped and processed before the original successor. Pick whichever you can write without bugs.

How do I prepare for this in 48 hours?+

Solve the standard flatten multilevel doubly linked list once, then redo it with index arrays and the [value, prev, next] output. Test three cases: nested children two levels deep, a single node, and empty input with headIndex = -1. That covers what Bloomberg reported in March 2026.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Bloomberg.

OA at Bloomberg?
Invisible during screen share
Get it