Algorithm · Bloomberg · Hard
Requirements You are given a doubly linked list whose nodes have prev, next, and child fields. A child field can reference a separate doubly linked list; nodes in that list can also reference children, creating a nested, tree-shaped layout. Create a function that converts this layout into one flat doubly linked list. Once it has been flattened: Whenever curr owns a child chain, place that entire chain after curr and before curr.next. Every child field in the flattened…
Checking your access…