Flatten a Branched Linked List into a Doubly Linked List

You are given a linked structure of nodes. Each node contains:

  • next: the next node on the main chain;
  • branch: an optional side-branch head;
  • prev: the previous pointer of the eventual doub...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: