码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
[LeetCode]Recover Binary Search Tree
【题目】 Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight forward. Could...
分类:其他好文   时间:2014-12-10 12:35:23    阅读次数:191
【LeetCode】Add Binary
Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".先进行对齐操作,然后从右往左逐位相加,注意进位即可。代码写的比较长,但是很...
分类:其他好文   时间:2014-12-10 12:20:23    阅读次数:196
LeetCode Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:其他好文   时间:2014-12-09 23:00:59    阅读次数:276
[LeetCode]Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. ...
分类:其他好文   时间:2014-12-09 17:58:42    阅读次数:186
保存一棵树根到叶子之和为给定值的所有路径的DFS解法
这道题目DFS用得非常不自信。 (1)递归的用得不够大胆,过分考虑细节了,应该站得高些。 (2)思路厘清之后,要注意状态值的修改,就是状态恢复。深度优先走到底之后,需要返回,此时对应的状态也应该返回。例如之前放到堆栈/vector里的状态数据要弹出来。 /** * Definition for binary tree * struct TreeNode { * int val;...
分类:其他好文   时间:2014-12-09 17:53:30    阅读次数:142
[LeetCode]Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota...
分类:其他好文   时间:2014-12-09 17:47:47    阅读次数:196
【leetcode】 Unique Binary Search Trees II (middle)☆
Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni...
分类:其他好文   时间:2014-12-09 15:23:03    阅读次数:178
【leetcode】 Unique Binary Search Trees (middle)☆
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1 ....
分类:其他好文   时间:2014-12-09 13:54:28    阅读次数:205
Log4j2.x的使用(Log4j1.x升级到Log4j2.x)
Log4j2.x相对Log4j1.x来说有了很大的改变,对于一个应用比较广泛的开源软件来说这种改变有些不必要,也不太人性化 准备工作 官方下载页面:http://logging.apache.org/log4j/2.x/download.html 选择Apache Log4j 2 binary 下载,不要选择source文件下载,如果您有兴趣去研究再打包,也未尝不可。(gz和zip只是...
分类:其他好文   时间:2014-12-09 12:17:51    阅读次数:957
[LeetCode]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: Giv...
分类:其他好文   时间:2014-12-09 12:14:27    阅读次数:164
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!