Leetcode 536. Construct Binary Tree from String
Reconstruct a binary tree from its preorder string representation where node values are integers and left/right children are given as parenthesized substrings (e.g., "4(2(3)(1))(6(5))"); parse nested parentheses and multi-digit/negative numbers and attach subtrees appropriately using recursion or a stack.
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early August, 2025
Meta
Senior
You need to construct a binary tree from a string consisting of parenthesis and integers.
Late March, 2025
Meta
Senior
Late February, 2025
Meta
Staff
Your account is free and you can post anonymously if you choose.