uva 11151 Longest PalindromeA palindrome is a string that reads the same from the left as it does from the right. For example, I, GAG and MADAM are palindromes, but ADAM is not. Here, we consider also...
分类:
其他好文 时间:
2015-05-06 17:56:58
阅读次数:
116
时间复杂度为O(N)的算法
在网上看到的很牛逼的算法,不是很理解,这里我就不说了,给链接点击打开链接
时间复杂度为O(N²)的算法-从中间向两边展开
回文字符串显然有个特征是沿着中心那个字符轴对称。比如aha沿着中间的h轴对称,a沿着中间的a轴对称。那么aa呢?沿着中间的空字符''轴对称。
所以对于长度为奇数的回文字符串,它沿着中心字符轴对称,对于长度为偶数的回文字符串,它...
分类:
其他好文 时间:
2015-05-06 17:48:55
阅读次数:
124
题目:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest...
分类:
其他好文 时间:
2015-05-06 17:07:28
阅读次数:
140
Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered fr...
分类:
其他好文 时间:
2015-05-06 12:33:09
阅读次数:
111
这个题目leetcode上提示用动态规划,但是那样要O(n^2)。我自己想出了一个O(n)的算法,并提交通过。【题目】Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
For "((...
分类:
编程语言 时间:
2015-05-06 11:00:58
阅读次数:
123
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-05-06 06:53:51
阅读次数:
135
原理参考:http://www.douban.com/note/321468038/public class Solution { public String longestPalindrome(String s) { if((s == null) || (s.length() ...
分类:
其他好文 时间:
2015-05-06 01:09:48
阅读次数:
145
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-05-05 23:42:33
阅读次数:
168
Problem:
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 lengt...
分类:
其他好文 时间:
2015-05-05 21:56:58
阅读次数:
134
求一个字符串中不含重复字母的最大子串的长度。【思路】1.用临时tmp记录长度,遇到重复字母把tmp当前值赋给要返回的length,tmp归零比较tmp和length,当tmp>length时,更新length。2.每个字母向前遍历是否有重复字母,用哈希表。3.反复提交代码不能通过后看了题目tag,知...
分类:
其他好文 时间:
2015-05-05 19:15:55
阅读次数:
156