LeetCode—105. Construct Binary Tree from Preorder and Inorder Traversal

LeetCode—105. Construct Binary Tree from Preorder and Inorder Traversal 题目 根据前序遍历和中序遍历建立二叉树。注意二叉树中没有重复的数字。 思路及解法 根据前序遍历和中序遍历的特点,通过前序遍历列表确定根节点,在中序遍历的列表里找出根节点,左边就是左子树,右边就是右子树,中序遍历列表确定左子树和右子树的长度,实际在递归过程中
相关文章
相关标签/搜索