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-08-05 13:58:32
阅读次数:
164
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo ...
分类:
其他好文 时间:
2016-08-05 13:37:00
阅读次数:
103
先要搞明白:最长公共子串和最长公共子序列的区别。 最长公共子串(Longest Common Substirng):连续 最长公共子序列(Longest Common Subsequence,LCS):不必连续 实在是汗颜,网上做一道题半天没进展: 给定一个字符串s,你可以从中删除一些字符,使得剩下 ...
分类:
其他好文 时间:
2016-08-05 00:57:05
阅读次数:
134
Longest Increasing Subsequence(LIS) 一个美丽的名字 非常经典的线性结构dp [朴素]:O(n^2) d(i)=max{0,d(j) :j<i&&a[j]<a[i]}+1 直接两个for [二分查找优化]:O(n^2) g(i):d值为i的最小的a 每次更新然后lo ...
分类:
其他好文 时间:
2016-08-05 00:49:46
阅读次数:
150
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 to any ...
分类:
其他好文 时间:
2016-08-04 23:02:10
阅读次数:
242
DescriptionWe say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is equal to { 1, …, p-1 }. For example, the consecutive powers...
分类:
其他好文 时间:
2016-08-03 18:45:00
阅读次数:
140
题目链接:hdu_1403_Longest Common Substring 题意: 给你两个字符串,然你找最长的公共子串 题解: 后缀数组的经典应用,要找两个字符串的公共子串,那么就相当于找两个串的后缀的最长公共前缀,我们将两个字符串拼接在一起,中间插一个特殊字符 然后我们考虑height数组,h ...
分类:
编程语言 时间:
2016-08-03 18:40:49
阅读次数:
205
POJ 2739 Sum of Consecutive Prime Numbers Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu POJ 2739 Sum of Consecutive Prime Numbers ...
分类:
其他好文 时间:
2016-08-03 10:24:45
阅读次数:
129
Given a string, find the longest substring that contains only two unique characters. For example, given "abcbbbbcccbdddadacb", the longest substring t ...
分类:
其他好文 时间:
2016-08-03 01:34:19
阅读次数:
193