1490. Clone N-Ary Tree

Given the root of an N-ary tree, create a deep copy (clone) of the tree. Each node in an N-ary tree has a value and a list of children nodes. The copy must have the same structure and the same values, but every node must be a newly allocated object.

The tree is passed as a flat integer array using a preorder encoding with explicit child counts. For each node, write its value, then the number of children, then recursively encode each child in order. An empty tree is the empty array. Return the flat encoding of the cloned tree, which has the same numbers as the input because cloning preserves values and structure.

Decoding uses a cursor: read the value, read the child count, advance the cursor by two, then decode that many children in order.

Examples
Input: [1,0]
Output: [1,0]
Hints

1490. Clone N-Ary Tree

Given the root of an N-ary tree, create a deep copy (clone) of the tree. Each node in an N-ary tree has a value and a list of children nodes. The copy must have the same structure and the same values, but every node must be a newly allocated object.