这道题一眼看上去就是一个递归的算法,对于一棵树,分三种情况,包括根、仅左子树、仅右子树,递归的确认最大值,其中第一种情况(路径中包含根)分析可知它会一直包含根,后两中就复杂点,需要一直递归处理每颗子树。代码如下:int maxPathSumWithRoot(TreeNode *root) { if ...
分类:
其他好文 时间:
2014-08-30 21:43:10
阅读次数:
307
- For now, CodeBlocks doesn't privide binary packages for CentOS7.(http://www.codeblocks.org/downloads/26#linux64)- In this thread(http://forums.codeb...
分类:
其他好文 时间:
2014-08-30 17:45:39
阅读次数:
237
C - Problem C
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
SubmitStatus
Problem Description
Consider an infinite complete binary tree where the root nod...
分类:
其他好文 时间:
2014-08-30 08:49:29
阅读次数:
232
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2014-08-30 02:22:18
阅读次数:
244
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
具体一位一位地加就行了,考虑进位的问题。还有最后记得把生成的string反过来再返回,因为我们是从最低位开始加的。
public class Solu...
分类:
其他好文 时间:
2014-08-30 01:16:58
阅读次数:
286
Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeN...
分类:
其他好文 时间:
2014-08-30 01:10:48
阅读次数:
333
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum
...
分类:
其他好文 时间:
2014-08-29 22:42:32
阅读次数:
328
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 you devis...
分类:
其他好文 时间:
2014-08-29 21:28:08
阅读次数:
313
# Definition for a binary tree nodeclass TreeNode: def __init__(self, x): self.val = x self.left = None self.right = Noneclas...
分类:
其他好文 时间:
2014-08-29 17:36:18
阅读次数:
135
一、ofbiz 用自身数据库安装 1. 由 binary 安装: 由 binary 安装非常简单, 以下是安装方法: 下载ofbiz-2.0-beta1-complete.tar.gz, 注意不是ofbiz-2.0-beta1.tar.gz. tar xvzf ofbiz-2.0.beta1-...
分类:
其他好文 时间:
2014-08-29 12:49:37
阅读次数:
251