码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
leetcode Symmetric Tree
这里是给定一个数,判断是不是对称的,即根据根画一竖直线对折重合一样。For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ ...
分类:其他好文   时间:2014-11-27 20:27:23    阅读次数:208
【LeetCode】Binary Tree Maximum Path Sum
Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be...
分类:其他好文   时间:2014-11-27 20:22:01    阅读次数:181
LeetCode:Binary Tree Zigzag Level Order Traversal
本题也属于层次遍历的变形,不同之处在于其遍历的方法是交替进行的,形成一个ZigZag的曲线形式,如下:代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* rig...
分类:其他好文   时间:2014-11-27 18:09:13    阅读次数:132
LeetCode:Binary Tree Level Order Traversal II
本题和上题一样同属于层次遍历,不同的是本题从底层往上遍历,如下:代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5 TreeNode(...
分类:其他好文   时间:2014-11-27 18:07:56    阅读次数:171
LeetCode:Binary Tree Level Order Traversal
题目:Binay Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level...
分类:其他好文   时间:2014-11-27 17:56:43    阅读次数:110
LeetCode:Maximum Depth of Binary Tree
要求:求二叉树的深度(二叉树的深度为最远叶子节点到根节点的距离,即根节点到最远叶子节点的距离)Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest ...
分类:其他好文   时间:2014-11-27 17:55:50    阅读次数:145
LeetCode:Construct Binary Tree from Preorder and Inorder Traversal
要求:通过二叉树的前序和中序遍历序列构建一颗二叉树代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x):...
分类:其他好文   时间:2014-11-27 17:49:13    阅读次数:220
LeetCode:Construct Binary Tree from Inorder and Postorder Traversal
要求:根据中序和后序遍历序列构建一棵二叉树代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x): val...
分类:其他好文   时间:2014-11-27 17:45:31    阅读次数:123
LeetCode:Balanced Binary Tree
要求:判断一棵树是否是平衡二叉树Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree i...
分类:其他好文   时间:2014-11-27 17:44:31    阅读次数:140
[Leetcode]Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key.Th...
分类:其他好文   时间:2014-11-27 16:30:19    阅读次数:226
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!