使用马拉车算法,时间复杂度为O(n),算法详细解释在上一篇文章中。//// main.cpp// Longest Substring//// Created by Bowie Hsu on 14/11/21.// Copyright (c) 2014年 Bowie Hsu . All ...
分类:
其他好文 时间:
2014-11-27 12:38:37
阅读次数:
137
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-11-27 07:59:55
阅读次数:
184
Description
Given an undirected weighted graph
G , you should find one of spanning trees specified as follows.
The graph G is an ordered pair
(V, E) , where V is a set of vertices
{v1, v2...
分类:
其他好文 时间:
2014-11-26 22:45:41
阅读次数:
364
问题描述:
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
For example,
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [...
分类:
其他好文 时间:
2014-11-26 22:39:47
阅读次数:
201
这里,我介绍一下O(n)回文串处理的一种方法。Manacher算法.原文地址:http://zhuhongcheng.wordpress.com/2009/08/02/a-simple-linear-time-algorithm-for-finding-longest-palindrome-sub-...
分类:
其他好文 时间:
2014-11-26 18:38:27
阅读次数:
167
很明显的2 pointer问题。。。当满足条件的时候后面的指针加,不满足条件的时候前面的指针加,直到满足条件。。。class Solution {public: int lengthOfLongestSubstringTwoDistinct(string s) { int sta...
分类:
其他好文 时间:
2014-11-26 16:10:45
阅读次数:
336
Annotation Order:It's considered good practice to dependency inject Angular's providers in before our own custom ones.Bad:// randomly ordered dependen...
分类:
Web程序 时间:
2014-11-25 18:16:10
阅读次数:
155
Write a function to find the longest common prefix string amongst an array of strings.思路:每个字符串都与第0个字符串比较,设置一个变量,记录每个字符串与第0个字符串不匹配位置的最小值 时间复杂度O(n1+n2.....
分类:
其他好文 时间:
2014-11-24 16:55:19
阅读次数:
244
记忆化搜索,跟以前的做过的 滑雪 一样的。
DP+DFS。用dp[][]保存搜索记录,然后满足条件累加即可。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x7ffffff...
分类:
其他好文 时间:
2014-11-24 13:37:30
阅读次数:
226
使用双指针,i遍历全部字符,start收集重复的次数,最后不重复出现的字符个数maxx为i-start+1;// main.cpp// Longest Substring//// Created by Bowie Hsu on 14/11/21.// Copyright (c) 2014年 Bowi...
分类:
其他好文 时间:
2014-11-24 13:21:59
阅读次数:
142