前序/中序遍历/树的重建/LeetCode 105

题目连接:https://leetcode-cn.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/web 首先,要明白preorder和inorder的关系,preorder中的第一个每每是那颗(子)树的根节点,在inorder中就能够把序列分为左右两半(左树、右树)。 这里选择前序遍历构造树:也就是先构
相关文章
相关标签/搜索