[Leetcode 3, Medium] Longest Substring Without Repeating Characters
分类:
其他好文 时间:
2015-08-13 14:18:23
阅读次数:
98
这道题目使用的方法具有非常大的普遍性,实际上是两个指针。一个指针记录当前所记录的子串的开始,另一个是当前遍历的位置,如果产生了重复,那么需要进行修正,实际上是对子串进行收缩。从当前子串开始位置到重复位置,重置相应的字符为违被搜索状态。在收缩之前需要进行,最长子串长度的更新。 1 public cla...
分类:
其他好文 时间:
2015-08-12 23:02:08
阅读次数:
121
问题描述: 给定两个序列 X=, Y,求X和Y长度最长的公共子串。(子串中的字符要求连续) 这道题和最长公共子序列(Longest common subsequence)很像,也可以用动态规划定义。公式如下:这里c[i,j]表示以Xi,Yj结尾的最长公共子串的长度。程序实现:int longes.....
分类:
其他好文 时间:
2015-08-12 21:13:28
阅读次数:
142
问题定义: 给定一个长度为N的数组A,找出一个最长的单调递增子序列(不要求连续)。 这道题共3种解法。1. 动态规划 动态规划的核心是状态的定义和状态转移方程。定义lis(i),表示前i个数中以A[i]结尾的最长递增子序列的长度。可以得到以下的状态转移方程:d(i) = max(1, d(j)...
分类:
其他好文 时间:
2015-08-12 18:43:08
阅读次数:
109
问题描述Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter...
分类:
其他好文 时间:
2015-08-11 15:55:30
阅读次数:
88
1040. Longest Symmetric String (25)Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is P...
分类:
其他好文 时间:
2015-08-11 15:33:47
阅读次数:
102
描述: A numeric sequence ofaiis ordered ifa1#include#include#include#include using namespace std;#define N 1005int main(){ int n,temp,dp[N],seq[N],c...
分类:
其他好文 时间:
2015-08-11 00:08:26
阅读次数:
174
Longest Ordered Subsequence
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 38980
Accepted: 17119
Description
A numeric sequence of ai is ordered if a1 a2 ...
分类:
其他好文 时间:
2015-08-10 09:25:24
阅读次数:
82
经典的最长公共子序列问题,我刚开始用string敲的,就是为了练练手,没想到竟然wa了,还以为我用错了呢。。。换了字符数还是wa。。。真无语,这么简单的题快把我弄糊涂了,后来听人说是输入可能有空格。。。这是巨坑啊,题上都没说清楚,白白wa了几发。。。就是设一个数组d[i][j]遍历两个字符数组当a[i]==b[j]的时候d[i][j]=d[i-1][j-1]+1。不相等的时候就是d[i][j]=m...
分类:
其他好文 时间:
2015-08-09 17:18:31
阅读次数:
123
Longest Common Prefix 解题报告...
分类:
其他好文 时间:
2015-08-09 12:33:24
阅读次数:
86