1 public class Solution { 2 public String get(String a,String b) 3 { 4 5 if(a==""||b=="") return ""; 6 int len1=a.le...
分类:
其他好文 时间:
2014-07-13 22:05:47
阅读次数:
238
public class Solution { public int longestConsecutive(int[] num) { HashSet hash=new HashSet(); int max=1; for(int n:num) ...
分类:
其他好文 时间:
2014-07-13 21:52:58
阅读次数:
244
当时不知道怎么下手,后来一看原来就是排个序然后乱搞就行了。解法不想写了,可见:http://blog.csdn.net/u013368721/article/details/28071241其实就是滑动窗口的思想。代码:#include #include #include #include #inc...
分类:
其他好文 时间:
2014-07-13 19:31:18
阅读次数:
212
题目来源,待字闺中,原创@陈利人
,欢迎大家继续关注微信公众账号“待字闺中”
原题这个LIS问题,可不是Longest Increasing Subsequence,而是Largest Independent Set,含义如下:给定一棵二叉树,找到满足如下条件的最大节点集合:集合中的任意两个节点之间,都没有边。如下图:
LIS大小为5,为{10,40,60,70,8...
分类:
其他好文 时间:
2014-07-12 23:20:18
阅读次数:
267
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 [1, 2, 3...
分类:
其他好文 时间:
2014-07-11 00:51:05
阅读次数:
195
Longest Ordered Subsequence
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 31787
Accepted: 13903
Description
A numeric sequence of ai is ordered if a1 a2...
分类:
其他好文 时间:
2014-07-10 20:27:45
阅读次数:
202
如果一个字符串从左向右写和从右向左写是一样的,这样的字符串就叫做palindromic string,如aba,或者abba。本题是这样的,给定输入一个字符串,要求输出一个子串,使得子串是最长的padromic string。
下边演示3种思路
1.两侧比较法
以abba这样一个字符串为例来看,abba中,一共有偶数个字,第1位=倒数第1位,第2位=倒数第2位......第N位=倒数第...
分类:
编程语言 时间:
2014-07-08 17:49:03
阅读次数:
238
SPOJ Problem Set (classical)
1812. Longest Common Substring II
Problem code: LCS2
A string is finite sequence of characters over a non-empty finite set Σ.
In this problem, Σ is...
分类:
其他好文 时间:
2014-07-08 17:14:39
阅读次数:
291
Write a function to find the longest common prefix string amongst an array of strings.
写一个函数找出字符串数组中的最长共现前缀字符串。
思路:共现,即要求数组中的所有元素的前缀中都要出现。所以所得的结果肯定是最短字符串的部分或全部或都不是,总之要以最短字符串为基准与其他字符串比较。
public Str...
分类:
其他好文 时间:
2014-07-08 10:39:49
阅读次数:
203
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 longest palindromic substring.
给定一个字符串S,找出其中的最长回文...
分类:
其他好文 时间:
2014-07-06 00:15:15
阅读次数:
240