LC: 431. Encode N ary Tree to Binary Tree - spiralgo/algorithms GitHub Wiki

431. Encode N-ary Tree to Binary Tree:

The Essence:

A node's siblings can be thought of as a linked list, descending as the right or left children. Its children can be thought of as another sibling linked list of their own, descending down from the opposite direction of the siblings.

Details:

The algorithm can be implemented recursively. We assume that we initially append all the children of the root in the left direction. To encode the children of the children, we call the children as the root for the same procedure but in the opposite direction. LC-431