Skip to content
StackDecode
Linked listsExplained

Flatten a Multilevel Linked List

Splice each child list into the main list after its parent.

Time

O(n)

Extra space

O(1)

Use it for

Nested list structures.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.