https://leetcode.com/problems/longest-substring-without-repeating-characters/
题目: 找一个字符串的连续子串,使得该子串里不含相同字母,求符合条件的最长的子串的长度。
算法: DP----后缀思想
最初考虑过用二分答案,发现复杂度应该是O(n*n*log(n)),其中n*n验证一个答案对不对,log(n)是...
分类:
其他好文 时间:
2015-05-09 20:31:16
阅读次数:
126
Longest Substring Without Repeating CharactersTotal Accepted:62719Total Submissions:298285My SubmissionsQuestionSolutionGiven a string, find the lengt...
分类:
其他好文 时间:
2015-05-09 20:23:00
阅读次数:
114
Substring with Concatenation of All Words问题:You are given a string,s, and a list of words,words, that are all of the same length. Find all starting in...
分类:
其他好文 时间:
2015-05-09 17:26:33
阅读次数:
98
Problem:
Write a function to find the longest common prefix string amongst an array of strings.
Solution:
时间复杂度O(n)
题目大意:
给一个字符串数组,要找到这些字符串的最大前缀公共子串。
解题思路:
既然是公共子串,那每个字符串肯定都包含有,并且在头部,首先把第...
分类:
编程语言 时间:
2015-05-08 20:22:43
阅读次数:
139
Write a function to find the longest common prefix string amongst an array of strings.
求若干字符串的最长公共前缀。
首先若无字符串,返回“”;接下来求得其中最短字符串的长度len,比较公共前缀只需最多比较len次;最后比较所有字符串里每一位上的字符。
class Solution {
public:
...
分类:
其他好文 时间:
2015-05-08 18:12:00
阅读次数:
152
reference:http://www.jb51.net/article/42482.htm使用 substring()或者slice() 函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组 例子: str=”jpg|bmp|gif|ico|png”; arr=theStr...
分类:
Web程序 时间:
2015-05-08 12:31:41
阅读次数:
145
Really interesting problem. Naive solution would be O(n^3). But please note the pattern here: (i, j, k) -> (i + 1, j + 1, k) -> (i + 2, j + 2, k)... t...
分类:
其他好文 时间:
2015-05-08 08:09:32
阅读次数:
202
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon...
分类:
编程语言 时间:
2015-05-07 20:11:27
阅读次数:
154
求字符串的最长回文子串。【思路】1.从两边开始向中间发展2.从中间开始向两边发展3.从中间开始的变体,较为复杂,详见http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html【other code1-...
分类:
其他好文 时间:
2015-05-07 11:45:27
阅读次数:
129
【题目】
Write a function to find the longest common prefix string amongst an array of strings.
【分析】
公共前缀指的是所有字符串的前缀都相同。显然,这个最长公共前缀的长度不会超过所有字符串中最短的那个。
我们先求得最短串长minLen,然后遍历所有字符串中的前...
分类:
其他好文 时间:
2015-05-07 08:45:58
阅读次数:
104