http://poj.org/problem?id=2533#include#include#include#includeusing namespace std;int num[1000+100];int dp[1000+100];int main(){ int n; int i,j;...
分类:
其他好文 时间:
2015-01-25 23:58:22
阅读次数:
308
【题目】
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once
an...
分类:
其他好文 时间:
2015-01-25 19:43:59
阅读次数:
191
题目:
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",
Return
[
...
分类:
编程语言 时间:
2015-01-25 16:41:55
阅读次数:
201
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 ...
分类:
其他好文 时间:
2015-01-25 16:34:51
阅读次数:
151
问题描述:字符序列的子序列是指从给定字符序列中随意地(不一定连续)去掉若干个字符(可能一个也不去掉)后所形成的字符序列。令给定的字符序列X=“x0,x1,…,xm-1”,序列Y=“y0,y1,…,yk-1”是X的子序列,存在X的一个严格递增下标序列,使得对所有的j=0,1,…,k-1,有xij=yj...
分类:
其他好文 时间:
2015-01-25 16:30:43
阅读次数:
253
后缀数组的用处:快速求出两个后缀Suffix(i), Suffix(j)的最长公共前缀(LCP, Longest Common Perfix)以下一张图片可谓简洁明了。下面贴上模板1.求最长重复子串,可以重叠void solve_duplicate_substr(int n){//duplicate...
分类:
编程语言 时间:
2015-01-25 15:04:43
阅读次数:
311
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-01-25 11:03:14
阅读次数:
129
Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba”,T is "ece" which ...
分类:
其他好文 时间:
2015-01-25 06:31:56
阅读次数:
141
原题地址以前可以用DP枚举所有回文串,但是Leetcode后来增加了几组大数据,用DP会超时。什么!用DP都超时了??那怎么办?答:二分法尝试可能的回文串长度,直到找到最大值需要注意的是,假设现在已经验证了长度为length的回文串不存在,传统的二分法就会去尝试长度为length/2的回文串是否存在...
分类:
其他好文 时间:
2015-01-24 19:57:26
阅读次数:
127
Write a function to find the longest common prefix string amongst an array of strings.
题意:求字符串数组的最长公共前缀
思路:首先找到最短的那个作为标尺,然后每次比较。
class Solution {
public:
string longestCommonPrefix(vector &st...
分类:
其他好文 时间:
2015-01-23 21:38:51
阅读次数:
147