问题:给定字符串S,求S中的最长回文子串。
本篇将讨论一个O(N)时间O(N)空间的算法,即著名的Manacher算法,并详细说明其时间复杂度为何是O(N)。
分类:
其他好文 时间:
2014-12-15 23:23:40
阅读次数:
356
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.
/**
* Definition for binary tree
...
分类:
其他好文 时间:
2014-12-15 21:52:22
阅读次数:
124
Write a function to find the longest common prefix string amongst an array of strings.
#include
#include
#include
char *longestCommonPrefix(char *strs[],int n)
{
int i,j,k;
char *res=(...
分类:
其他好文 时间:
2014-12-15 20:24:22
阅读次数:
174
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2014-12-15 00:00:53
阅读次数:
329
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...
分类:
其他好文 时间:
2014-12-14 00:38:30
阅读次数:
161
Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s = “eceba”,T is "ece" which...
分类:
其他好文 时间:
2014-12-13 06:07:09
阅读次数:
137
题目为:
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.
阶梯思路:对于这种题目最简单的方法就是递归操作了...
分类:
其他好文 时间:
2014-12-12 23:40:13
阅读次数:
374
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...
分类:
其他好文 时间:
2014-12-12 11:49:07
阅读次数:
132
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 longes...
分类:
其他好文 时间:
2014-12-12 06:43:52
阅读次数:
120
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...
分类:
其他好文 时间:
2014-12-11 22:33:05
阅读次数:
403