码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
[LeetCode] Binary Tree Inorder Traversal 中序排序
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:编程语言   时间:2015-03-18 01:04:11    阅读次数:209
【LeetCode】 Sum Root to Leaf Numbers
第一次写的解法,。对于只有一个儿子的节点重复了两次 。。结果就弄复杂了。。我也觉得不应该能有这么多的重复嘛 /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ...
分类:其他好文   时间:2015-03-17 22:00:13    阅读次数:130
【LeetCode】 Populating Next Right Pointers in Each Node 完全二叉树
题目:Populating Next Right Pointers in Each Node /* * LeetCode Populating Next Right Pointers in Each Node * 题目:为树的每个节点增加一个next指针,指向树状结构排列时自己的右边节点,如果右边没有节点则置为null * * Definition for binary tree wit...
分类:其他好文   时间:2015-03-17 21:54:58    阅读次数:107
Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:其他好文   时间:2015-03-17 21:45:00    阅读次数:103
Sum Root to Leaf Numbers
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:其他好文   时间:2015-03-17 21:28:07    阅读次数:118
Binary Tree Postorder Traversal
Binary Tree Postorder Traversal问题:Given a binary tree, return thepostordertraversal of its nodes' values.思路: 栈方法我的代码:public class Solution { publi...
分类:其他好文   时间:2015-03-17 21:24:17    阅读次数:123
【LeetCode】 Recover Binary Search Tree BST 中序遍历
题目:Recover Binary Search Tree /* * LeetCode: recover the binary search tree * 题目:二叉树中有两个节点被交换了位置,找出它们,并且将它们换回来,要求用o(n)的连续空间 * 知识点:1、BST树的特点:中序遍历后的节点的排列是按照非降的顺序 * 思路:按照特点中序遍历,当遇到逆序的节点则按照保存相关节点,注...
分类:其他好文   时间:2015-03-17 20:16:07    阅读次数:114
【LeetCode】 Same Tree
题目:Same Tree /** * LeetCode Same Tree * 题目:判断两棵树是否是完全相同的 * 思路:完全相同:1、结构相同; * 2、值相同。 * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * ...
分类:其他好文   时间:2015-03-17 20:14:14    阅读次数:127
【LeetCode】Symmetric Tree 判断一棵树是否是镜像的
题目:Symmetric Tree /**LeetCode Symmetric Tree 对称的树 * 思路:判断一棵树是否对称,1.有左子树就要有右子树 * 2.除根节点外对称节点值要相同 * 注意:对称后就是左子树的左节点和右子树的右节点比较 * Definition for binary tree * public class TreeNode { *...
分类:其他好文   时间:2015-03-17 20:13:33    阅读次数:149
Minimum Depth of Binary Tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:其他好文   时间:2015-03-17 20:01:14    阅读次数:98
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!