Problem 431 · Hard

Encode N-ary Tree to Binary Tree

Encode an N-ary tree as a binary tree and decode it back, using a first-child and next-sibling layout. The visual draws each node's first child on the left and its next sibling on the right.

Open the interactive visualisation