文章 2015-05-01 来自:开发者社区

[LeetCode]*106.Construct Binary Tree from Inorder and Postorder Traversal

题目 Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 思路 思路和[LeetCode]*105.Construct Binary Tree from Preo...

文章 2015-04-28 来自:开发者社区

[LeetCode]*105.Construct Binary Tree from Preorder and Inorder Traversal

题目 Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 思路 主要是根据前序遍历和中序遍历的特点解决这个题目。 1、确定树的根节点。树根是当前树中所有元素在前序...

文章 2015-03-03 来自:开发者社区

【LeetCode从零单排】No102 Binary Tree Level Order Traversal

题目        Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3,9,20...

文章 2015-02-24 来自:开发者社区

[LeetCode] Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive solution is trivial, could you do it iterativel...

文章 2015-02-24 来自:开发者社区

[LeetCode] Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive solution is trivial, could you do it iteratively...

文章 2014-12-15 来自:开发者社区

[LeetCode 第12题] -- Binary Tree Postorder Traversal

题目链接: Binary Tree PostOrder Trveral 题目意思: 给定一棵二叉树,求后续遍历序列 代码: /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(i...

文章 2014-12-09 来自:开发者社区

[LeetCode]103.Binary Tree Zigzag Level Order Traversal

【题目】 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Gi...

文章 2014-12-08 来自:开发者社区

[LeetCode]102.Binary Tree Level Order Traversal

【题目】 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 ....

文章 2014-12-07 来自:开发者社区

[LeetCode]145.Binary Tree Postorder Traversal

【题目】 Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution ...

文章 2014-11-27 来自:开发者社区

LeetCode: 106_Construct Binary Tree from Inorder and Postorder Traversal | 根据中序和后序遍历构建二叉树 | Medium

要求:根据中序和后序遍历序列构建一棵二叉树 代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x): val(x),left(NULL), right(NULL) {} 6 }; 7 ...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注