Given an unsorted array of integers, find the
length of the longest consecutive elements sequence.For example,Given[100, 4,
200, 1, 3, 2],The longest ...
分类:
其他好文 时间:
2014-07-22 23:16:14
阅读次数:
408
Given a string, find the length of the longest
substring without repeating characters. For example, the longest substring
without repeating letters fo...
分类:
其他好文 时间:
2014-07-22 23:11:32
阅读次数:
388
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 farthest le...
分类:
其他好文 时间:
2014-07-22 23:07:13
阅读次数:
379
题目: Given a string, find the length of the longest
substring without repeating characters. For example, the longest substring
without repeating letter...
分类:
其他好文 时间:
2014-04-30 21:15:32
阅读次数:
511
Problem description:given a string, find the
longest palindrome string in itSolution:1.brute force O(n^3)just enumerate start
and end of the substring...
分类:
其他好文 时间:
2014-04-29 17:22:46
阅读次数:
308
2014-04-28 23:35题目:最大子数组和问题。解法:O(n)解法。代码: 1 //
17.8 Find the consecutive subarray with maximum sum in an array. 2 // O(n)
online algorithm. 3 #include...
分类:
其他好文 时间:
2014-04-29 16:35:28
阅读次数:
429
这道题中要求时间复杂度为O(n),首先我们可以知道的是,如果先对数组排序再计算其最长连续序列的时间复杂度是O(nlogn),所以不能用排序的方法。我一开始想是不是应该用动态规划来解,发现其并不符合动态规划的特征。最后采用类似于LRU_Cache中出现的数据结构(集快速查询和顺序遍历两大优点于一身)来...
分类:
其他好文 时间:
2014-04-28 10:21:19
阅读次数:
1003