关键在于写好helperpublic class Solution { public String longestPalindrome(String s) { if(s==null) return null; if(s.length()==1) return s; ...
分类:
其他好文 时间:
2015-05-29 00:51:42
阅读次数:
149
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without
repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
分类:
其他好文 时间:
2015-05-28 19:59:44
阅读次数:
129
写完之后看到网上很多人的做法是暴力匹配,其实不用这样的。
我们只要先将字符串排序,那么如果相邻的两个字符串一定前缀匹配度最高,那么我们只需要遍历一遍,每次比较当前字符串和它的前一个字符串的前缀,
得出len,然后取所有len中的最小值即可。
注意特判size为0和1的情况。时间8ms
class Solution {
public:
string longestCommonPref...
分类:
编程语言 时间:
2015-05-28 18:07:22
阅读次数:
182
第三道题Longest
Substring Without Repeating Characters如下:
public class Solution {
public int lengthOfLongestSubstring(String s) {
HashMap hs = new HashMap();
int maxl = 0;...
分类:
编程语言 时间:
2015-05-28 08:15:38
阅读次数:
264
因子(factor)和有序因子(ordered factor)因子用来存储类别变量(categorical variables)和有序变量,这类变量不能用来计算而只能用来分类或者计数。因子表示分类变量,有序因子表示有序变量。生成因子数据对象的函数是factor(),语法是factor(data, l...
分类:
编程语言 时间:
2015-05-27 15:13:27
阅读次数:
134
Problem Description
Given n integers.
You have two operations:
U A B: replace the Ath number by B. (index counting from 0)
Q A B: output the length of the longest consecutive increasing subseque...
分类:
其他好文 时间:
2015-05-27 10:22:54
阅读次数:
174
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the...
分类:
其他好文 时间:
2015-05-26 17:54:40
阅读次数:
123
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of ...
分类:
其他好文 时间:
2015-05-26 12:19:11
阅读次数:
144
题目描述:
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 ...
分类:
其他好文 时间:
2015-05-26 10:43:32
阅读次数:
129
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1 ...
分类:
其他好文 时间:
2015-05-25 16:50:52
阅读次数:
79