Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2015-07-20 18:38:42
阅读次数:
93
#include upper_bound(a,a+n,x);查找到x最后一个并返回下一个地址。lower_bound(a,a+n,x);查找到第一个x并返回他的地址。binary_bound(a,a+n,x);查找x,返回Bool。sort(a,a+n,compare)/(v.begin(),v.e...
分类:
其他好文 时间:
2015-07-20 16:17:32
阅读次数:
128
题目:
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
...
分类:
编程语言 时间:
2015-07-20 14:36:18
阅读次数:
128
DescriptionSeiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to ...
分类:
其他好文 时间:
2015-07-20 10:48:24
阅读次数:
109
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1 1 /** 2 * Definition for a binary tre...
分类:
其他好文 时间:
2015-07-20 10:35:00
阅读次数:
93
Problem DescriptionWe have met so many problems on the tree, so today we will have a query problem on a set of trees.There are N nodes, each node will...
分类:
其他好文 时间:
2015-07-20 10:30:30
阅读次数:
92
Write a function that takes an unsigned integer and returns the number of ’1' bits it hasFor example, the 32-bit integer ’11' has binary representatio...
分类:
其他好文 时间:
2015-07-20 10:29:37
阅读次数:
104
After loooong pause, adding next (well, second) post to the “series“. This time, I'd like to describe how logging works. And I don't mean binary loggi...
分类:
数据库 时间:
2015-07-20 09:05:20
阅读次数:
201
114 Flatten Binary Tree to Linked List这道题就是Preorder的稍微变种, 记住 pre 的节点就好class Solution: def __init__(self): self.pre = TreeNode("dummy") ...
分类:
其他好文 时间:
2015-07-20 08:01:33
阅读次数:
127
Title:有两个不同大小的二进制树:T1有上百万的节点;T2有好几百的节点。请设计一种算法,判定T2是否为T1的子树class Solution {public: /** * @param T1, T2: The roots of binary tree. * @return...
分类:
其他好文 时间:
2015-07-19 23:23:04
阅读次数:
222