码迷,mamicode.com
首页 >  
搜索关键字:longest consecutive    ( 3017个结果)
ZOJ- 2136 Longest Ordered Subsequence
相比 HDOJ 的 fatmouse‘s speed 这道题只需要输出 最长子序列的长度#includeusing namespace std;#define Size 1000int main(){ int N1; int table[Size+1]; i...
分类:其他好文   时间:2015-07-08 22:07:17    阅读次数:110
leetCode 32.Longest Valid Parentheses (有效的最大括号) 解题思路和方法
Longest Valid Parentheses  Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid par...
分类:其他好文   时间:2015-07-08 19:08:38    阅读次数:115
北大ACM2739——Sum of Consecutive Prime Numbers
题目的意思是:给你一个数N,求由连续的m个素数之和等于N的组数。 这题很简单,一开始没看到题目是连续的素数,所以一开始想用深搜来做,可是不行,后来再看了题目,才知道是连续的素数,是连续的素数就简单很多了。 下面的是 AC的代码: #include using namespace std; int prime[10005]; int main() { int i, j, k; for...
分类:其他好文   时间:2015-07-08 14:42:03    阅读次数:107
#3 Longest Substring Without Repeating Characters
在一个字符串中,找出最长不重复字符子串的长度。
分类:其他好文   时间:2015-07-08 10:49:34    阅读次数:125
014 Longest Common Prefix
想法很直接 复杂度O(mn)class Solution: # @param {string[]} strs # @return {string} def longestCommonPrefix(self, strs): n = len(strs) if...
分类:其他好文   时间:2015-07-08 08:14:36    阅读次数:139
hdu4055 dp
http://acm.hdu.edu.cn/showproblem.php?pid=4055 Problem Description The signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutat...
分类:其他好文   时间:2015-07-07 21:17:12    阅读次数:367
128 Longest Consecutive Sequence
这道题一开始无从下手,想到找到用hashtable,这样查询没个数是否在List中只需要O(1)时间。以上是第一步, 接下来的想法就比较自然, 将每个数都当成可能的起始点进行测试。待测试的起始点为n,如果n-1在set中,则n必不为起始数字,可以continue优化运行时间代码中使用set来实现ha...
分类:其他好文   时间:2015-07-07 10:50:22    阅读次数:120
LeetCode104_MaximumDepthofBinaryTree Java题解
题目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 解题: 求最大深度  和前面一题类似  用递归遍历就...
分类:编程语言   时间:2015-07-06 16:06:14    阅读次数:143
Longest Palindromic Substring - 一题多解
题意是寻找一个字符串的最大回文字串,最简单的是n3方的算法,由于字符串最大长度为1000,所以这个方法很危险而且不科学。紧接着想到的是一个n方的算法:回文子串是从中间向两边产生的,那么对于每个字符考察这个字符往外的所有可能不就可以找到以这个字符为中心的最长回文子串了吗?当然要考虑偶数的情况,即那个中...
分类:其他好文   时间:2015-07-06 15:51:01    阅读次数:106
CF dp 一句话解题
wyq说刚入门oi 或是遇到瓶颈的时候就刷DP吧,虽然觉得这么刷CF题有点浪费,但是还是挺爽的,按照solved排序做的,前面的题都挺水的(忘记记录了混蛋),就不写了,从5C开始写解题CF5 C. Longest Regular Bracket Sequence:题目大意,给一个括号序列,让你求最长...
分类:其他好文   时间:2015-07-06 15:36:02    阅读次数:94
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!