leetcode -Invert Binary Treenvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Defini...
分类:
其他好文 时间:
2015-08-21 01:37:53
阅读次数:
132
leetcode - Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in...
分类:
其他好文 时间:
2015-08-20 23:58:08
阅读次数:
393
题目:
Given a binary tree, return all root-to-leaf paths.
For example, given the following binary tree:
1
/ 2 3
5
All root-to-leaf paths are:
["1->2->5", "1->3"]
...
分类:
编程语言 时间:
2015-08-20 22:38:02
阅读次数:
259
可能没想到,人的简单方法,关于质询的问题提出做。如何把产生出来的所有的树木?所使用的方法当然是递归,但是有一个致命的问题,假设根节点,然后做一个递归,所以这是非常多的公共树木的根,结果肯定是一团糟。怎么办?事实上,在思想上先实践的数量目前正在寻求高度统一,先把全部的左右子树都求出来。然后把它们之间的...
分类:
其他好文 时间:
2015-08-20 22:32:55
阅读次数:
215
先序遍历,用递归来做,简单的不能再简单了。代码如下:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ...
分类:
其他好文 时间:
2015-08-20 22:18:26
阅读次数:
179
RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序”
rpm 执行安装包
二进制包(Binary)以及源代码包(Source)两种。二进制包可以直接安装在计算机中,而源代码包将会由RPM自动编译、安装。源代码包经常以src.rpm作为后缀名。
常用命令组合:
-ivh:安装显示安装进度--install--ve...
分类:
其他好文 时间:
2015-08-20 19:03:33
阅读次数:
252
Hardwood Species
Time Limit: 10000MS
Memory Limit: 65536K
Total Submissions: 20811
Accepted: 8158
Description
Hardwoods are the botanical group of trees that have broad...
分类:
其他好文 时间:
2015-08-20 16:53:18
阅读次数:
99
题目:
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 unique BST's.
1 3 3 2 ...
分类:
编程语言 时间:
2015-08-20 15:22:03
阅读次数:
180
Recursion, a natural thought:class Solution { // Top : BottomRight std::pair rotate(TreeNode *p) { if (!p->left && !p->right) ...
分类:
其他好文 时间:
2015-08-20 14:44:10
阅读次数:
133
题目:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].N...
分类:
其他好文 时间:
2015-08-20 12:20:26
阅读次数:
115