码迷,mamicode.com
首页 >  
搜索关键字:longest consecutive    ( 3017个结果
LeetCode Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 要减少比较次数。在实现过程中我的想法是,2个2个比较,那么只要遍历一次数组就好。而且,在比较过程中,以较短的那个长度作为最大比...
分类:其他好文   时间:2014-05-26 21:29:43    阅读次数:203
leetcode:Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes...
分类:其他好文   时间:2014-05-24 04:45:39    阅读次数:245
LeetCode:Longest Substring Without Repeating Characters(最长不重复子串)
题目链接Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter...
分类:其他好文   时间:2014-05-24 02:15:57    阅读次数:291
LeetCode: Maximum Depth of Binary Tree 题解
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 le...
分类:其他好文   时间:2014-05-23 11:54:10    阅读次数:317
Maximum Depth of Binary Tree
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 le...
分类:其他好文   时间:2014-05-22 16:05:56    阅读次数:239
leetcode Longest Common Prefix
找出单词的最长公共前缀 class Solution { public: string longestCommonPrefix(vector &strs) { int len=strs.size(); if(len==0) return ""; int length=strs[0].size(),j; ...
分类:其他好文   时间:2014-05-22 09:35:20    阅读次数:230
【动态规划初级】longest increasing subsequence
一个序列有N个数:A[1],A[2],A[3]……A[N],求最长非降子序列的长度。最重要的是要找出所谓的“状态”,本题目中是d[i],初始化最长长度为自己本身即一个单位长度。看是否要加入第i个元素,如果第i个元素a[i]比当前序列的最后一个元素a[j]大的话,那么加入,同时d[i]=d[j]+1;...
分类:其他好文   时间:2014-05-22 05:54:06    阅读次数:228
算法——动态规划篇——最长公共子序列
问题描述      最长公共子序列,英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。       解决最长公共子序列,一种常用的办法,就是穷举法,组合出所有的情况,但是这样对于长序列的情况来说,是非常不实际。。 假设现在有...
分类:其他好文   时间:2014-05-21 13:55:35    阅读次数:260
LeetCode: Longest Valid Parentheses [031]
【题目】 Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()", which has length = 2. Another example is ")()())", whe...
分类:其他好文   时间:2014-05-20 16:39:07    阅读次数:280
LeetCode 014 Longest Common Prefix
【题目】 Write a function to find the longest common prefix string amongst an array of strings. 【题意】 求一组字符串的最长公共前缀 【思路】 使用归并思想求解 要求字符串[1,2,..,k,k+1,...n]的最大公共前缀,先分别求[1,2,...k]和[k+1,...,n]的公共前缀...
分类:其他好文   时间:2014-05-18 05:17:53    阅读次数:232
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!