码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
LeetCode 124. Binary Tree Maximum Path Sum
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
分类:其他好文   时间:2016-03-02 20:04:23    阅读次数:178
LeetCode -- Construct Binary Tree from Preorder and Inorder
Question: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. Ana
分类:其他好文   时间:2016-03-02 18:10:08    阅读次数:153
144. 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 [1,2,3]. 解题思路: 题目很简单,就是求一个二叉
分类:其他好文   时间:2016-03-02 17:45:10    阅读次数:142
LeetCode -- Validate Binary Search Tree
Question: 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 con
分类:其他好文   时间:2016-03-02 14:53:15    阅读次数:127
LeetCode: Binary Tree Level Order Traversal 层序遍历二叉树
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
分类:其他好文   时间:2016-03-02 14:48:42    阅读次数:136
LeetCode 199. Binary Tree Right Side View
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x),
分类:其他好文   时间:2016-03-01 22:45:03    阅读次数:195
LeetCode 144. Binary Tree Preorder Traversal
前序遍历 递归: 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x)
分类:其他好文   时间:2016-03-01 22:31:17    阅读次数:183
LeetCode 103. Binary Tree Zigzag Level Order Traversal
思路:维护两个stack<TreeNode*> stk1, stk2,stk1存放当前层的节点,stk2存放下一层的节点。 bool right表示下一层的顺序,如果为True则下一层为从右到左,因为stk2是stack,所以stk2先存cur->left,然后存cur->right。 当stk1为
分类:其他好文   时间:2016-03-01 22:21:45    阅读次数:192
LeetCode(100):Same Tree
Same Tree:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally id...
分类:其他好文   时间:2016-03-01 21:00:42    阅读次数:171
LeetCode(110): Balanced Binary Tree
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 tr...
分类:其他好文   时间:2016-03-01 20:44:24    阅读次数:153
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!