这个好多算法书上都有,不仅限于《算法导论》
时间限制:3000 ms | 内存限制:65535 KB
难度:3
描述
咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。
tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ...
分类:
其他好文 时间:
2015-06-03 15:54:35
阅读次数:
124
题目传送门 1 /* 2 题意:求最长括号匹配的长度和它的个数 3 贪心+stack:用栈存放最近的左括号的位置,若是有右括号匹配,则记录它们的长度,更新最大值,可以在O (n)解决 4 详细解释:http://blog.csdn.net/taoxin52/article/d...
分类:
其他好文 时间:
2015-06-03 15:11:51
阅读次数:
130
又水,素数只能是连续的,而且最多才10000! 1 #include 2 3 using namespace std; 4 5 int a[10001]; 6 7 bool is_prime(int x) 8 { 9 if(x == 1) return 0;10 for...
分类:
其他好文 时间:
2015-06-02 21:25:09
阅读次数:
122
Euler discovered the remarkable quadratic formula:
n² + n + 41
It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40...
分类:
其他好文 时间:
2015-06-02 11:16:49
阅读次数:
139
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. For ...
分类:
其他好文 时间:
2015-06-02 09:24:48
阅读次数:
113
public class Solution { public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } ...
分类:
其他好文 时间:
2015-06-02 06:50:27
阅读次数:
110
这道题最大的问题是位置容易想不清楚public class Solution { public int longestValidParentheses(String s) { // http://blog.csdn.net/linhuanmars/article/details/...
分类:
其他好文 时间:
2015-06-02 06:47:55
阅读次数:
124
Java Longest Palindromic Substring(最长回文字符串)...
分类:
编程语言 时间:
2015-06-02 00:27:16
阅读次数:
326
Description
The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "a...
分类:
编程语言 时间:
2015-06-01 22:36:06
阅读次数:
262
string CommonPrefix(string str1,string str2){ int len_1=str1.length(); int len_2=str2.length(); int min_len=len_1>len_2 ? len_2:len_1; str...
分类:
其他好文 时间:
2015-06-01 13:09:54
阅读次数:
92