Write a function to find the longest common prefix string amongst an array of strings. 题目的描述很简单,就是求多个字符串公共前缀,其实可以考虑先对字符向量用sort()进行排序,然后从前向后遍历,复杂度为O(S) ...
分类:
其他好文 时间:
2017-12-03 15:35:06
阅读次数:
161
Write a function to find the longest common prefix string amongst an array of strings.第二遍做法:时间复杂度应该是O(m*n),m表示字符串的最大长度,n表示字符串的个数,空间复杂度应该是O(m),即字符串的长度 ... ...
分类:
其他好文 时间:
2017-12-03 13:00:03
阅读次数:
186
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 1. O(n2 * l)复杂度做 ...
分类:
其他好文 时间:
2017-12-02 11:15:19
阅读次数:
120
Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other wo ...
分类:
其他好文 时间:
2017-11-30 11:56:38
阅读次数:
123
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This ...
分类:
其他好文 时间:
2017-11-29 21:59:49
阅读次数:
120
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: 寻找最长回文字符串。 用动态规划。dp[i][j] ...
分类:
其他好文 时间:
2017-11-29 16:09:05
阅读次数:
140
这些一次遍历搞定的,套路无非都是在遍历的时候就记录数据的状态,然后根据遍历到的当前的数据的状态来修改最终结果,当遍历完了的时候结果也就确定了。 题目来源: http://www.lintcode.com/zh-cn/problem/longest-words/ ...
分类:
其他好文 时间:
2017-11-26 11:16:30
阅读次数:
111
class Solution { public: string longestPalindrome(string s) { int len=s.size(); int left,right; int begin=0,maxlen=0; if(len=0&&rightmaxlen) { ... ...
分类:
其他好文 时间:
2017-11-25 20:01:42
阅读次数:
113
Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. I ...
分类:
其他好文 时间:
2017-11-25 16:12:03
阅读次数:
215
Assume s is a string of lower case characters. Write a program that prints the longest substring of s in which the letters occur in alphabetical order ...
分类:
编程语言 时间:
2017-11-24 22:47:36
阅读次数:
176