Leetcode 1028. Recover a Tree From Preorder Traversal
Reconstruct a binary tree from a preorder string where each node is represented by its value prefixed with D dashes indicating its depth (root depth 0) and any single child is guaranteed to be the left child. The challenge is to parse depth/value pairs and attach nodes at the correct depths (e.g., via a depth-indexed stack or recursive construction) to rebuild and return the tree.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.