Write a function to find the longest common prefix string amongst an array of strings.把输入strs当做二维数组,对每一列j, 检查strs[0...n-1][j]是否相同。 1 string longestCom...
分类:
其他好文 时间:
2015-01-13 19:38:59
阅读次数:
144
求一个字符串的最长回文子串。回文子串分为两种,一种是aba型的,一种是abba型的,因此两种情况都有考虑到。用一个循环,对字符串中的每一个字符作为中心进行判断,并记录下每个循环后的最长子串。时间复杂度为O(n*n)
之前写了一个程序可以运行,但是在leetcode中运行超时了。下面的是修改别人的程序,很精简。
{CSDN:CODE:578916}...
分类:
其他好文 时间:
2015-01-13 17:53:08
阅读次数:
166
题意:
给一个字符串,然后找一个子串,使子串满足其中连续重复子串最多。
比如ababab,重复次数为3,ababa,重复次数为1(abab是两次)
恶心在于还要输出最小字典序。
题解网上都有,不发了。
代码:
#include
#include
#include
#include
#define N 101000
#define LOGN 20
#define...
分类:
编程语言 时间:
2015-01-13 15:58:20
阅读次数:
256
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 ...
分类:
其他好文 时间:
2015-01-13 15:45:26
阅读次数:
126
这一段一直忙考试,一直没有刷题,今天上来刷三道题感觉生疏起来了。。罪过啊。刷到今天了。。还是没有写算法的感觉,还是写代码太少了。java的用法又忘记了很多。java上手后就要开始写python了,反正现在就是没有写代码的感觉。题目:Longest Common Prefix通过率:26.5%难度:简...
分类:
其他好文 时间:
2015-01-13 13:51:15
阅读次数:
193
1.join(separator) :将数组转化成以separator为分隔符的字符串2.split(separator) :使用一个指定的分隔符(separator)把一个字符串分割存储到数组3.indexof():返回字符串中匹配子串的第一个字符的下标4.substring()::字符串截取注意...
分类:
Web程序 时间:
2015-01-13 12:16:00
阅读次数:
131
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/longest-palindromic-substring/Given a string S, find the ...
分类:
编程语言 时间:
2015-01-13 01:21:57
阅读次数:
285
求字符串中的最长无重复子串的长度,例如"abcabcbb",最长无重复子串为"abc",长度为3。因为要求无重复,因此想到要用HashMap来保存,因为HashMap的键值不能重复。将要存入的字符作为key,字符在字符串中的下标作为value,如果map中已经存有该字符,则删掉该字符以及字符串中该字符之前的所有字符,然后再存入。例如字符串为"abcbd",如已存入abc,现在要存b,则删掉ab,存...
分类:
其他好文 时间:
2015-01-12 11:38:25
阅读次数:
217
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/Given a st...
分类:
编程语言 时间:
2015-01-12 01:36:33
阅读次数:
255
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-01-11 22:58:44
阅读次数:
223