原题地址:http://oj.leetcode.com/problems/binary-tree-level-order-traversal/题意:二叉树的层序遍历的实现。解题思路:二叉树的层序遍历可以用bfs或者dfs来实现。这里使用的dfs实现,代码比较简洁。实际上,二叉树的先序遍历就是dfs实...
分类:
编程语言 时间:
2014-05-14 03:25:59
阅读次数:
428
原题地址:http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/题意:Given
a binary tree, flatten it to a linked list in-place.For example,Given...
分类:
编程语言 时间:
2014-05-12 05:30:32
阅读次数:
367
看了下JAVA里面有HashMap、Hashtable、HashSet三种hash集合的实现源码,这里总结下,理解错误的地方还望指正HashMap和Hashtable的区别HashSet和HashMap、Hashtable的区别HashMap和Hashtable的实现原理HashMap的简化实现My...
分类:
其他好文 时间:
2014-05-12 01:46:52
阅读次数:
413
原题地址:http://oj.leetcode.com/problems/sum-root-to-leaf-numbers/题意:Given
a binary tree containing digits from0-9only, each root-to-leaf path could
repre...
分类:
编程语言 时间:
2014-05-12 01:28:30
阅读次数:
440
一直没有点动态树这个科技树,因为听说只能用Splay,用Treap的话多一个log。有一天脑洞大开,想到也许Treap也能从底向上Split。仔细思考了一下,发现翻转标记不好写,再仔细思考了一下,发现还是可以写的,只需要实时交换答案二元组里的两棵树,最后在吧提出来的访问节点放回去就行了。本着只学.....
分类:
其他好文 时间:
2014-05-11 22:56:42
阅读次数:
605
C++ 11已将哈希表纳入了标准之列。hashtable是hash_set、hash_map、hash_multiset、hash_multimap的底层机制,即这四种容器中都包含一个hashtable。
解决碰撞问题的办法有许多,线性探测、二次探测、开链等等。SGI STL的hashtable采用的开链方法,每个hash table中的元素用vector承载,每个元素称为桶(bucke...
分类:
其他好文 时间:
2014-05-11 21:07:54
阅读次数:
522
题目链接:点击打开链接
题意比较明显,不赘述。
删除时可以把i-1转到根,把i+1转到根下
则i点就在 根右子树 的左子树,且只有i这一个 点
#include
#include
#include
#include
using namespace std;
#define N 300500
#define inf 10000000
#define L(x) tree[x].ch[0]
#d...
分类:
其他好文 时间:
2014-05-11 21:05:52
阅读次数:
365
起因ledisdb是一个参考ssdb,采用go实现,底层基于leveldb,类似redis的高性能nosql数据库,提供了kv,list,hash以及zset数据结构的支持。我们现在的应用极大的依赖redis,但随着我们用户量越来越大,redis的内存越来越不够用,并且replication可能还会导致超时问题。虽然后续我们可以通过添加多台机器来解决,但是在现有机器配置下面,我们仍希望单台机器承载...
分类:
数据库 时间:
2014-05-11 05:39:12
阅读次数:
522
题目
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,...
分类:
其他好文 时间:
2014-05-11 03:25:24
阅读次数:
298
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie
Maximum Depth of Binary Tree
Total Accepted: 16605 Total
Submissions: 38287
Given a binary tree, find its maximum depth.
...
分类:
其他好文 时间:
2014-05-11 01:58:31
阅读次数:
441