典型的栈的应用。创建 stack<TreeNode*>Stack.
遇到左括号就把current入栈;
遇到右括号就退栈一个元素作为current的父节点:根据规则,current优先作为左子节点,如果父节点已经有左子节点,则current作为它的右子节点。然后更新current为此时的那个父节点。
遇到数字串,则开辟新节点current并赋值。注意负号。
GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — LeetCode/Stack/536.Construct-Binary-Tree-from-String at master · wisdompeak/LeetCode Expand file tree/ Copy path536.Construct-Binary-Tree-from-String/Directory actionsMore optionsMore optionsDirectory actionsMore optionsMore options/ Copy path536.Construct-Binary-Tree-from-String/Folders and files
典型的栈的应用。创建 stack<TreeNode*>Stack. 遇到左括号就把current入栈; 遇到右括号就退栈一个元素作为current的父节点:根据规则,current优先作为左子节点,如果父节点已经有左子节点,则current作为它的右子节点。然后更新current为此时的那个父节点。 遇到数字串,则开辟新节点current并赋值。注意负号。 | |||||||||||||||||||||
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | |||||||||||||||||||||