[抄题]: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: [暴力解法] ...
分类:
其他好文 时间:
2018-07-29 12:55:39
阅读次数:
120
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2018-07-28 00:12:27
阅读次数:
119
给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n2) 。 进阶: 你能将算法的时间复杂度降低到 O(n log n) 吗? 首先是O(n^2)的算法,就是用一个数组a来存储到某个位 ...
分类:
其他好文 时间:
2018-07-26 15:21:08
阅读次数:
136
Question "594. Longest Harmonious Subsequence" Solution 题目大意:找一个最长子序列,要求子序列中最大值和最小值的差是1。 思路:构造一个map,保存每个元素出现的个数,再遍历这个map,算出每个元素与其邻元素出现的次数和,并找到最大的那个数 J ...
分类:
其他好文 时间:
2018-07-22 22:24:02
阅读次数:
164
问题描述: Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node ...
分类:
其他好文 时间:
2018-07-22 11:19:50
阅读次数:
166
Given an array of strings, return another array containing all of its longest strings. Example For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the ...
分类:
其他好文 时间:
2018-07-22 00:23:41
阅读次数:
155
传送门: http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 61731 Accepted: 27632 Descr ...
分类:
其他好文 时间:
2018-07-21 22:52:45
阅读次数:
273
题目如下: 解题思路:从头开始遍历string,用left和right分别表示左括号和右括号的数量,并用index记录起始下标。如果遇到left = right,表示这一段区间是合法的括号子串;如果right > left,表明这一段区间是不合法的,需要从index开始依次右移缩短区间,直到left ...
分类:
其他好文 时间:
2018-07-20 16:42:56
阅读次数:
104
iter(iterable) 可以生成一个迭代器。 例子: islice(iterator, int, int) itertools的islice方法为迭代器生成器提供切片操作。 例子: izip_longest(iterable, iterable) itertools的izip_longest方 ...
分类:
编程语言 时间:
2018-07-19 20:58:22
阅读次数:
188
LCS2 - Longest Common Substring II 链接 题意: 求N(N<=10)个串的最长公共子串。 分析: poj2774上那道题,对一个串建立后缀自动机,另一个在上面匹配。 这道题是对多个串求。那么同样,让每个串在后缀自动机上匹配,然后记录在后缀自动机的每个节点上记录,当前 ...
分类:
其他好文 时间:
2018-07-19 16:19:25
阅读次数:
129