语言:Python描述:使用递归实现 1 # Definition for a binary tree node 2 # class TreeNode: 3 # def __init__(self, x): 4 # self.val = x 5 # self...
分类:
其他好文 时间:
2014-07-09 20:46:34
阅读次数:
168
题目
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent
a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123.
Find ...
分类:
其他好文 时间:
2014-07-08 21:43:08
阅读次数:
219
不同进制的书写方式
八进制(Octal) 0o377十六进制(Hex) 0xFF二进制(Binary) 0b11111111
不同进制之间的转换
python提供了三个内置的函数,可以用来在不同进制间做转换。
>>> oct(255), hex(255), bin(255)
('0o377', '0xff', '0b11111111')
还可以使用int函数,把字符串转成数值
>...
分类:
编程语言 时间:
2014-07-08 20:53:09
阅读次数:
195
Mozilla工程师通过优化Static Initializer(静态初始化,或全局建构函数, Global Constructor)和Binary布局来提升FireFox启动速度的文章,非常有参考价值。文章中以x86及x86-64平台为基础,下面加了Mac OS及Android上的binary布局。什么是Static Initializer? 简而言之就是全局C++对象的初始化。...
分类:
其他好文 时间:
2014-07-08 17:55:40
阅读次数:
278
Unique Binary Search Trees
My Submissions
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
For example,
Given n = 3, there are a total of 5 uniqu...
分类:
其他好文 时间:
2014-07-08 14:18:39
阅读次数:
159
Description
Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root node is X, we can get the minimum number in this ...
分类:
其他好文 时间:
2014-07-06 11:36:14
阅读次数:
284
定义
二叉搜索树(Binary Search Tree)或称二叉查找树,也称二叉排序树(Binary Sort Tree)。它或者是一棵空树,或者是具有下列性质的二叉树:
若左子树不空,则左子树上所有节点的值均小于它的根节点的值;
若右子树不空,则右子树上所有节点的值均大于它的根节点的值;
左、右子树也分别为二叉搜索树;
性质
二叉搜索树与普通二叉树相比,有一些优秀的特征或性质:
由于节点是有序排放的:左子树<根节点<右子树。故在查找一个节点的时候,只需先和根节点比较,再决定是进入左子树还是右子树查找。...
分类:
其他好文 时间:
2014-07-06 11:06:37
阅读次数:
167
deb包的构建的命令为:
dpkg-buildpackage
这样会自动完成所有从源代码包构建二进制包的工作,包括以下几个步骤:
0、清理源代码树(debian/rules clean)
1、构建源代码包(dpkg-source -b)
2、构建程序(debian/rules build)
3、构建二进制包(fakeroot debian/rules binary)...
分类:
其他好文 时间:
2014-07-06 10:38:33
阅读次数:
1940
本题使用所谓的辗转相除法。
还需要逆过来遍历二叉树。可以想象给出的数据点是根节点,然后遍历到根节点(1,1)。
考的是根据给出的规则,总结规律的能力。
#include
namespace BinaryTree2499_1
{
int main()
{
int T, a, b, le, ri;
scanf("%d", &T);
for (int t = 1; t <= T; t...
分类:
其他好文 时间:
2014-07-06 08:11:00
阅读次数:
164
非常简单的一个题,和path sum非常类似。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *rig...
分类:
其他好文 时间:
2014-07-05 22:03:48
阅读次数:
251