Problem 2 ---Add Two Numbers简单的模拟题。Problem 3 ---Longest Substring Without Repeating Characters题意: 给定一个字符串序列,找出最长无重复的子序列。如"abcabcbb"的最长不重复子序列为"abc"思路: ...
分类:
其他好文 时间:
2015-04-10 19:28:51
阅读次数:
100
4.Median of Two Sorted Arrays
5.Longest Palindromic Substring
6.ZigZag Conversion...
分类:
编程语言 时间:
2015-04-10 11:36:28
阅读次数:
149
题目:Given a string, find the length of the longest substring without repeating characters.For example, the longest substring without repeating letters ...
分类:
其他好文 时间:
2015-04-10 07:00:16
阅读次数:
120
Problem Description
Given two strings, you have to tell the length of the Longest Common Substring of them.For example:
str1 = banana
str2 = cianaicSo the Longest Common Substring is “ana”, and the...
分类:
编程语言 时间:
2015-04-09 15:33:59
阅读次数:
225
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-04-09 15:18:13
阅读次数:
115
我们假设成立数列的首相和末项分别为a和b, 由求和公式可得(a+b)*(b-a-1)/2==n;再设a+b=x,b-a+1=y,则有方程组 x*y=n*2, 两式相加得x+y=2*b+1,故有x+(2*n/x)=2*a-1
因此我们只要检测能被2*n整除且使上面方程满足中a为正整数的情况(b比a大,b就不用判断了),由于3*5与5*3是同一种情况,所以只需要从1循环到sqrt(n) ,889ms...
分类:
其他好文 时间:
2015-04-08 18:17:35
阅读次数:
116
得到一个string序列的最长公共前缀。【思路】先求得最小string的长度,使得比较次数尽可能少。对于要返回的prefix的每一位,从第一个string中取一个字符,拿来和其他string同样位置的字符比较;如果不相同,则返回当前的prefix,否则添加到prefix后。【注意】读取第i个stri...
分类:
其他好文 时间:
2015-04-08 10:50:46
阅读次数:
81
1.Two Num
2.Add Two Numbers
3.Longest Substring Without Repeating Characters...
分类:
编程语言 时间:
2015-04-08 09:14:09
阅读次数:
200
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-04-08 00:54:17
阅读次数:
113
题意:给一字符串,求一个子串的长度,该子串满足所有字符都不重复。字符可能包含标点之类的,不仅仅是字母。按ASCII码算,就有2^8=128个。思路:从左到右扫每个字符,判断该字符距离上一次出现的距离是多少,若大于max,则更新max。若小于,则不更新。每扫到一个字符就需要更新他的出现位置了。这里边还...
分类:
其他好文 时间:
2015-04-07 23:16:50
阅读次数:
153