这两道题用递归的解法都很简单,只是稍有不同。下面是AC代码: 1 /** 2 * Given a
binary tree, find its minimum depth. 3 * the minimum depth is the number of
nodes along th...
分类:
其他好文 时间:
2014-05-10 08:47:32
阅读次数:
271
不断递归的实现!!!!下面是AC代码: 1 /** 2 * Given inorder and
postorder traversal of a tree, construct the binary tree. 3 * @param inorder 4 *
@param...
分类:
其他好文 时间:
2014-05-10 08:40:40
阅读次数:
297
这道题因为不仔细的缘故两次过,与Maximum Depth of Binary
Tree问题类似,区别在于这个问题中,如果一个节点左子树为空、右子树有值,则该节点的深度应取决于右子树,而不能直接取min{左,右} 1 /** 2 *
Definition for binary tree 3 * .....
分类:
其他好文 时间:
2014-05-10 01:40:13
阅读次数:
293
用VC实现post数据常常会遇到URL编码问题在此封装一个工具类进行UTF8编码的转换源码来自php
source code只是简单的封装给C++调用[cpp]view
plaincopy//URL编解码类//来自PHP源码classCRtUrlConv{public:staticchar*urle...
分类:
其他好文 时间:
2014-05-09 18:41:25
阅读次数:
455
A heap is a partially sorted binary tree.
Although a heap is not completely in order, it conforms to a sorting principle:
every node has a value less ...
分类:
其他好文 时间:
2014-05-09 17:34:18
阅读次数:
339
http://source.android.com/source/downloading.html1.下载repo官网:curl
http://commondatastorage.googleapis.com/git-repo-downloads/repo >
~/bin/repo目前我啥下载不了。...
分类:
移动开发 时间:
2014-05-09 12:31:27
阅读次数:
397
1 /** 2 * Definition for binary tree 3 * public
class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 *
TreeNo...
分类:
其他好文 时间:
2014-05-09 12:16:45
阅读次数:
232
感谢spencerzou的博文:http://blog.csdn.net/spencerzou/article/details/24255189题目:有一个弱智的翻译程序,它接收一个文本文件作文输入源source.txt,通过查找给定的字典dictionary.txt,进行一一对应的翻译,并讲翻译结...
分类:
其他好文 时间:
2014-05-09 11:36:26
阅读次数:
448
这两道题,大同小异。
我都是用BFS,在遍历的过程,判断结构是否相同/对称,值是否相同。下面是AC代码: 1 /** 2 * Given a binary tree, check
whether it is a mirror of itself (ie, symmetric aroun...
分类:
其他好文 时间:
2014-05-05 09:48:26
阅读次数:
401
BFS以及它的扩展,我发现栈是个很好用的数据结构,特别是对于顺序需要颠倒的时候!!!这里有个重要的信息:可以用null来标识一个level的结束!!!下面是AC代码:
1 /** 2 * Given a binary tree, return the bottom-up level ord...
分类:
其他好文 时间:
2014-05-05 09:46:06
阅读次数:
402