码迷,mamicode.com
首页 >  
搜索关键字:longest substring    ( 5540个结果
Longest Substring Without Repeating Characters
public class Solution { public int lengthOfLongestSubstring(String s) { int max = 0; if (s == null || s.length() == 0...
分类:其他好文   时间:2015-05-07 07:36:02    阅读次数:143
HackerRank# The Longest Common Subsequence
原题地址LCD,经典动归,O(n^2)复杂度因为要输出子序列,所以啰嗦一些 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 #define MAX_...
分类:其他好文   时间:2015-05-07 00:45:34    阅读次数:107
Maximum Depth of Binary Tree -- leetcode
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 基本思路: 深度优先遍历。 在leetcode上实行执行时间...
分类:其他好文   时间:2015-05-06 23:08:25    阅读次数:184
KMP算法
对于KMP算法,最重要的是要把握其中的next数组的含义及求法考虑一个模式字符串:b1b2...bn,定义next[s]如下:next[s] is the longest proper prefix of b1b2...bs that is also a suffix of b1b2...bs#in...
分类:编程语言   时间:2015-05-06 21:08:11    阅读次数:143
LeetCode 5 Longest Palindromic Substring(C,C++,Python,Java)
Problem: 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. Soluti...
分类:编程语言   时间:2015-05-06 17:58:34    阅读次数:183
uva 11151 Longest Palindrome (最长公共子序列)
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
LeetCode(5) Longest Palindromic Substring
时间复杂度为O(N)的算法 在网上看到的很牛逼的算法,不是很理解,这里我就不说了,给链接点击打开链接 时间复杂度为O(N²)的算法-从中间向两边展开 回文字符串显然有个特征是沿着中心那个字符轴对称。比如aha沿着中间的h轴对称,a沿着中间的a轴对称。那么aa呢?沿着中间的空字符''轴对称。 所以对于长度为奇数的回文字符串,它沿着中心字符轴对称,对于长度为偶数的回文字符串,它...
分类:其他好文   时间:2015-05-06 17:48:55    阅读次数:124
【Longest Palindromic Substring】cpp
题目: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
【leetcode with java】32 Longest Valid Parentheses O(n)
这个题目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
[LeetCode] Longest Substring Without Repeating Characters 最长无重复子串
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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!