Recover a Tree From Preorder Traversal
We run a preorder depth-first traversal on a binary tree. At each node we output D dashes (D is the depth of the node), followed by the node's value (the root has depth 0). If a node has only one chil...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
