Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4...
分类:
其他好文 时间:
2014-08-07 18:13:20
阅读次数:
171
题目:uva10405 - Longest Common Subsequence(LIS,最长共同自序列)
题目大意:找出两个字符串中的最长公共的子序列。
解题思路:这类问题是第一次接触,不知道怎么做。百度了一下,发现了递推公式:dp【i】【j】:代表第一个字符串的前i个字符和第二个字符串的前j个字符比较能得到的最长的公共子序列。s【i】 == s【j】 ,dp【i】【j】...
分类:
其他好文 时间:
2014-08-06 23:04:32
阅读次数:
243
Your intuition would tell you that there's a O(n) solution. Actually it is another stack-based problem to solve.class Solution {public: struct Rec ...
分类:
其他好文 时间:
2014-08-06 14:37:41
阅读次数:
186
2D DP is an intuitive solution of course, but I got an MLE error, so I simplified it into a 1D DP:class Solution {public: void goDp(vector &dp, int...
分类:
其他好文 时间:
2014-08-06 06:14:40
阅读次数:
196
先上题目:Longest Common SubstringTime Limit: 8000/4000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4010Accepted Submissi...
分类:
其他好文 时间:
2014-08-05 18:43:09
阅读次数:
255
题目原文:
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of
S is 1000, and there exists one unique longest palindromic substring.
题意解析:
最长回文子串。就是...
分类:
其他好文 时间:
2014-08-05 15:56:59
阅读次数:
290
找出单词的最长公共前缀class Solution {public: string longestCommonPrefix(vector &strs) { int len=strs.size(); if(len==0) return ""; ...
分类:
其他好文 时间:
2014-08-05 00:09:58
阅读次数:
192
LCS是两个序列相似性的一种度量方法;若序列s1:2,5,7,9,3,1,2 s2:3,5,3,2,8则LCS为:5,3,2思路可参考:http://www.csie.ntnu.edu.tw/~u91029/LongestCommonSubsequence.html具体代码实现为: 1 #in...
分类:
其他好文 时间:
2014-08-04 13:47:37
阅读次数:
290
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo....
分类:
编程语言 时间:
2014-08-04 04:10:26
阅读次数:
374
题目:
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3....
分类:
其他好文 时间:
2014-08-03 23:29:46
阅读次数:
283