NeetCode #472LC-1028HardTrees
← Back to All Problems

#472 · #1028 · Recover a Tree From Preorder Traversal(从先序遍历还原二叉树)

📌 Problem Statement & Constraints

We run a pre-order depth-first search on a binary tree, outputting D dashes followed by the node value, where D is the node's depth. Given this traversal string, reconstruct the tree. Constraints: 1 <= traversal.length <= 10^5, node values are positive integers.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!