题目: 解题思路:1、简单思路:暴力破解法,时间复杂度O(n^3),肯定通不过。 2、动态规划法:(一般含“最XX”等优化词义的题意味着都可以动态规划求解),时间复杂度O(n^2),空间复杂度O(n^2)。 形如"abba", "abbba"这样的字符串,如果用dp[i][j]表示从下标i到j之间的 ...
分类:
其他好文 时间:
2016-04-06 11:03:39
阅读次数:
202
水题。枚举中间,暴力算最远的。也可以用(Manacher) ...
分类:
其他好文 时间:
2016-04-06 09:24:33
阅读次数:
143
原问题描述如下。 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], ...
分类:
其他好文 时间:
2016-04-05 22:38:53
阅读次数:
246
补充:zip迭代器和zip_longest迭代器 python3中的zip是可迭代的对象,可以节省内存空间 zip(*iterables) #构造函数 zip拼接多个可迭代对象iter1,iter2...的元素,返回新的可迭代对象,其元素为各系列iter1,iter2...对象元素组成的元组。如果各 ...
分类:
编程语言 时间:
2016-04-05 16:21:38
阅读次数:
219
文章目录如下 (1)自己的思路 (2)自己的代码 (3)别人的思路 (4)别人的代码 (5)对比自己的不足之处 题目如下: Write a function to find the longest common prefix string amongst an array of strings. ( ...
分类:
其他好文 时间:
2016-04-05 02:00:44
阅读次数:
117
Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical ...
分类:
其他好文 时间:
2016-04-04 14:31:54
阅读次数:
118
Given a string, find the length of the longest substring T that contains at most k distinct characters. For example, Given s = “eceba” and k = 2, T is ...
分类:
其他好文 时间:
2016-04-04 09:11:32
阅读次数:
290
A simple variation to "Longest Substring with At Most Two Distinct Characters". A typical sliding window problem. ...
分类:
其他好文 时间:
2016-04-04 06:44:56
阅读次数:
123
本文转自:http://www.cnblogs.com/TenosDoIt/p/3675788.html 题目链接 Given a string S, find the longest palindromic substring in S. You may assume that the maxim ...
分类:
其他好文 时间:
2016-04-03 22:05:20
阅读次数:
260