← ALL NOTES
String

1028. Recover a Tree From Preorder Traversal

A tree is encoded as a preorder string where each node's value is prefixed by as many dashes as its depth; rebuild the tree. A node with one child is always a left child. The dashes are the key:…

Loading…