Ezvor

1490. Clone N-ary Tree

MediumHash Table Preparing judge… LeetCode
Hash TableTreeDepth-First SearchBreadth-First Search

Hints

Hint 1
Traverse the tree, keep a hashtable with you and create a clone node for each node in the tree.
Hint 2
Start traversing the original tree again and connect each child pointer in the cloned tree the same way as the original tree with the help of the hashtable.