码迷,mamicode.com
首页 >  
搜索关键字:longest consecutive    ( 3017个结果)
15-1有向无环图中的最长路径
#ifndef LONG_PATH_H#define LONG_PATH_H#include#include#define MAX 65535int graphPath_longest(int (*Graph)[5],int Length,int origin,int destin ); void ...
分类:其他好文   时间:2015-07-17 20:54:10    阅读次数:212
15-2求最大回文的长度
#ifndef PALINDROME_H_#define PALINDROME_H_#include#includeint palindrome_longest(char *str,int front,int back); #endif #include"Palindrome.h"#define M...
分类:其他好文   时间:2015-07-17 20:52:05    阅读次数:238
leetcode longestCommonPrefix
题目:     Write a function to find the longest common prefix string amongst an array of strings. 就是要求一些字符串的最长公共前缀。 code:    class Solution { public: string longestCommonPrefix(vector& strs) {...
分类:其他好文   时间:2015-07-17 14:09:38    阅读次数:116
POJ-2533-Longest Ordered Subsequence(LIS模板)
Description A numeric sequence of ai is ordered if a1 #include #include using namespace std;int main(){ int n,i,j,a[1005],d[1005]; while(scanf("...
分类:其他好文   时间:2015-07-16 19:05:49    阅读次数:104
[leetcode] Longest Palindromic Substring 多种解法
很经典的题目,求字符串中的最长回文子串。 (1)最朴素的解法 ---暴力 复杂度O(N³) 这也是最容易想到的方法,最外层循环枚举起点i,第二层循环从i+1开始向后枚举,第三层判断是不是回文串。最后取最长子串的返回。 代码比较简单,这里没有列出。 (2)中心扩展法。复杂度O(N²) 枚举每一个字符作为中心点向左右扩展。但是这里要注意,对于每一次扩展要分奇偶两种情况。否则可能会漏掉情况。 ...
分类:其他好文   时间:2015-07-16 09:52:23    阅读次数:141
Longest Palindromic Substring
现在还不是总结动态规划的时候,这次遇到了动态规划的新的一种:矩阵法(自己创的),可以是一维也可以是二维,更多为很少见。随着刷题量的增大,务必好好总结动态规划是什么,有哪些种类。class Solution { public: string longestPalindrome(string s) { int length = s.size(); int arr[1...
分类:其他好文   时间:2015-07-15 22:56:32    阅读次数:132
POJ 2739 Sum of Consecutive Prime Numbers-数论-(连续素数和)
题意:求有多少种连续素数和是n,n的范围:2~10000 分析:预处理出10000内的素数,然后每输入一个n就用二重循环找出sum==n的个数,因为素数约为1200个,O(n^2)不会超时 代码: #include #include #include #include #define max(a,b) a>b?a:b using namespace std; int n,prim[5000]...
分类:其他好文   时间:2015-07-14 18:19:17    阅读次数:124
[LeetCode] Maximum Depth of Binary Tree
Question: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 fa...
分类:其他好文   时间:2015-07-14 17:15:29    阅读次数:106
[LeetCode] Longest Substring with At Most Two Distinct Characters
Problem DescriptionGiven a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba...
分类:其他好文   时间:2015-07-14 13:20:40    阅读次数:95
032 Longest Valid Parentheses
题目:032 Longest Valid Parentheses这道题是典型的堆栈应用class Solution: # @param {string} s # @return {integer} def longestValidParentheses(self, s): ...
分类:其他好文   时间:2015-07-14 13:18:22    阅读次数:102
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!