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/ \2 3Ret...
分类:
其他好文 时间:
2014-12-24 07:35:49
阅读次数:
227
【题目】
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
/ 2 3
Re...
分类:
其他好文 时间:
2014-12-23 22:41:29
阅读次数:
257
Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there...
分类:
其他好文 时间:
2014-12-23 00:07:39
阅读次数:
142
想了一晚上没想明白,上网搜了别人的答案。。。研究了好几个晚上才觉得有点明悟了。。。 下面是详细思考的过程:(参考答案) class Solution {
public: // 用桶排序 // 算出相邻两个桶之间的最大差值 // 如果是平均分布,则桶的数目和元素的数目相同时,其排序的时间复杂度是0(n...
分类:
其他好文 时间:
2014-12-22 22:45:04
阅读次数:
178
"结巴"中文分词的R语言版本,支持最大概率法(Maximum Probability),隐式马尔科夫模型(Hidden Markov Model),索引模型(QuerySegment),混合模型(MixSegment),共四种分词模式,同时有词性标注,关键词提...
分类:
编程语言 时间:
2014-12-22 11:24:00
阅读次数:
661
Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there...
分类:
其他好文 时间:
2014-12-21 23:28:50
阅读次数:
224
class Solution {public: int maxProduct(int A[], int n) { if (A == NULL || n res) { res = tr; } if (tr ...
分类:
其他好文 时间:
2014-12-21 15:14:01
阅读次数:
128
class Solution {public: int maximumGap(vector &num) { int len = num.size(); int gap = 0; sort(num.begin(), num.end()); ...
分类:
其他好文 时间:
2014-12-21 12:38:51
阅读次数:
147
梅西刚梅开二度,我也记一题。在一个没排序的数组里,找出排序后的相邻数字的最大差值。要求用线性时间和空间。如果用nlgn的话,直接排序然后判断就可以了。so easyclass Solution {public: int maximumGap(vector &num) { if (...
分类:
其他好文 时间:
2014-12-21 01:50:48
阅读次数:
263
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [...
分类:
其他好文 时间:
2014-12-20 20:51:21
阅读次数:
386