Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ 2 5
/ \ 3 4 6
The flattened tree should look like:
1
...
分类:
其他好文 时间:
2015-05-11 09:03:58
阅读次数:
107
Problem Description
Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,fa...
分类:
其他好文 时间:
2015-05-11 09:00:54
阅读次数:
221
题目大意:给出一些字符串表示二叉树,字符串的格式如下(n,s),n表示节点上的数,s表示该节点在哪个位置,问这些字符串能否组成二叉树解题思路:能否组成二叉树,首先需要判断根节点。
接着判断一下其他节点,按层次遍历的顺序来枚举,所以要先排序,按字符串的长度来排序。
如果该节点能是二叉树的节点,那么他的父节点就要存在
判断他的父节点是否存在,只需判断他的前len-1(len表示长度)个字符组成的串...
分类:
其他好文 时间:
2015-05-11 08:56:39
阅读次数:
123
题目来自于LeetCode
https://leetcode.com/problems/binary-tree-maximum-path-sum/
Binary Tree Maximum Path Sum
Total Accepted: 37936 Total
Submissions: 178064My Submissions
Question
Solutio...
分类:
其他好文 时间:
2015-05-11 00:05:34
阅读次数:
125
mysql查询默认不区分大小写,这在用户登录验证等情况下明显行不通。不过可以加一个关键字,binary,用二进制查询的方式。而在thinkphp中没有这个查询条件,只好用原生sql查询实现。publicfunction loginCheck(){ $username = I('para...
分类:
Web程序 时间:
2015-05-10 23:48:32
阅读次数:
183
DescriptionConsider all the sequences with length (0#include#includeusing namespace std;int dp[45][2];int main(){ int n,k; dp[1][0] = dp[1][1]= ...
分类:
其他好文 时间:
2015-05-10 22:00:04
阅读次数:
164
Description
Zuosige always has bad luck. Recently, he is in hospital because of pneumonia. While he is taking his injection, he feels extremely bored. However, clever Zuosige comes up with a new ga...
分类:
其他好文 时间:
2015-05-10 20:35:16
阅读次数:
150
Title:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST'...
分类:
其他好文 时间:
2015-05-10 20:14:33
阅读次数:
126
题目传送门 1 /* 2 dp[i][1]/dp[i][0] 表示从左往右前i个,当前第i个放1或0的方案数 3 k -= dp[n][0] 表示当前放0的方案数不够了,所以必须放1,那么dp[n][0]个方案数都不能用了 4 相当于k减去这么多 5 详细解释:htt...
分类:
其他好文 时间:
2015-05-10 18:55:07
阅读次数:
120
树状数组(Binary Indexed Tree(BIT), Fenwick Tree)是一个查询和修改复杂度都为log(n)的数据结构。主要用于查询任意两位之间的所有元素之和,但是每次只能修改一个元素的值;经过简单修改可以在log(n)的复杂度下进行范围修改,但是这时只能查询其中一个元素的值。树状...
分类:
编程语言 时间:
2015-05-10 18:47:59
阅读次数:
181