LC: Construct Binary Tree from String - spiralgo/algorithms GitHub Wiki
Construct Binary Tree from String
The Essence:
The binary tree data structure is recursively defined. So is the string that represents this data structure in this problem. When a parentheses is encountered, the next node can be recursively parsed to be the left or right node of the current root.
Details:
For this recursive definition of the string, a stack or recursion can be used. Closed-parenthesis would represent end of a parsing of the node too.