/** * Definition for binary tree * struct
TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :
val(x), left(...
分类:
其他好文 时间:
2014-07-22 23:07:34
阅读次数:
312
Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-07-22 23:07:13
阅读次数:
379
Definition: see
wikihttp://en.wikipedia.org/wiki/Binary_search_tree 1 /* 2 This look up is a
fast operation because you eliminate the half 3 t...
分类:
其他好文 时间:
2014-07-22 23:06:34
阅读次数:
330
题目:
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.
翻译:
给定一个有序数组(递增),写程序构建一棵具有最小高度的二叉树。
思路:
要使二叉树的高度最小,则要尽量使其左右子树的节点数目相当,自然就考虑到将其构造成为二叉排序树,且将有序数组的中间大的数作为根节点,这样得到的二叉树的高度便是最小的。...
分类:
其他好文 时间:
2014-05-01 17:48:45
阅读次数:
321
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 identical an...
分类:
其他好文 时间:
2014-05-01 16:06:46
阅读次数:
427
Given a binary tree, determine if it is
height-balanced.For this problem, a height-balanced binary tree is defined as a
binary tree in which the depth...
分类:
其他好文 时间:
2014-05-01 14:38:39
阅读次数:
454
这道题需要注意的地方有以下一些:1.
求从子树中的某节点到当前节点的最大路径不能采用递归方法,因为这个部分会被反复的调用,如果用递归,会使得之前已经计算过的节点被重复计算,使得时间复杂度特别高;2.
树中有节点的值是负数的。下面是AC代码。(我发现AC并不代表代码真的完全正确!!) 1 /** 2 ...
分类:
其他好文 时间:
2014-05-01 12:10:52
阅读次数:
274
qt有一套资源管理系统,如果将资源编译到可执行文件中,则可以直接访问可执行文件中的资源文件,
访问方式如下
:/prefix/location
但有的时候可以因为资源比较大,所以我们需要把资源编译成外部二进制资源文件*.rcc文件,这样可以提高可执行文件的加载速度。
编译方式rcc -binary myresource.qrc -o myresource.rcc
然后通过
QResou...
分类:
其他好文 时间:
2014-04-30 22:14:39
阅读次数:
487
泛型的Binary Search Tree的实现,并与STL map进行操作性能上的比较...
分类:
其他好文 时间:
2014-04-29 13:27:22
阅读次数:
420
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路同十进制的大数相加。代码如下:
class Solution {
public:
string addBinary(string a, str...
分类:
其他好文 时间:
2014-04-29 13:12:20
阅读次数:
328