Nearest Common AncestorsTime Limit:1000MSMemory Limit:10000KTotal Submissions:17720Accepted:9393DescriptionA rooted tree is a well-known data structur...
分类:
其他好文 时间:
2014-07-31 02:43:35
阅读次数:
327
题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthes....
分类:
编程语言 时间:
2014-07-31 02:41:15
阅读次数:
229
题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the neares....
分类:
编程语言 时间:
2014-07-31 02:30:25
阅读次数:
264
题目: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 /...
分类:
编程语言 时间:
2014-07-31 02:28:25
阅读次数:
376
题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identica....
分类:
编程语言 时间:
2014-07-31 02:24:15
阅读次数:
211
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, 1 ...
分类:
其他好文 时间:
2014-07-30 20:33:34
阅读次数:
193
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n)
space is pretty straight...
分类:
其他好文 时间:
2014-07-30 17:46:04
阅读次数:
244
题目链接:点击打开链接
题意:
问有多少个与矩阵边平行的直角三角形,且三角形的3个顶点都是*
对于 L形 或者_| 形的三角形,我们只需要知道在_ 上方有多少个*即可,下底边则任取2个
所以用l[i]表示 第i列的*的个数
然后扫完一行,再把这行的*更新到 l[] 里
从上到下扫一遍得到所有 L _| 的三角形
再从下到上扫一遍 得到 ~| 和 |~ 的。。
#in...
分类:
其他好文 时间:
2014-07-30 17:30:54
阅读次数:
173
UVA 11525 - Permutation
题目链接
题意:给定一个k个数字,求第n个全排列,由于n很大,输入的方式为∑k1Si?(K?i)!
思路:全排列,很容易看出,前面的si对应的就是数组中第k小的数字,那么问题变成每次找第k小的数字,然后去掉这个数字,这个用树状数组很容易实现
代码:
#include
#include
#define lowbit(...
分类:
其他好文 时间:
2014-07-30 17:25:44
阅读次数:
167
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center)....
分类:
其他好文 时间:
2014-07-30 14:48:53
阅读次数:
216