Given a string,find the length of the longest substring without repeating characters. Forexample, the longest substring without repeating letters for"abcabcbb" is "abc", which the length is 3. For"bbb...
分类:
其他好文 时间:
2015-07-21 12:54:53
阅读次数:
84
Longest Prefix给定一堆小字符串,问最长可以组成给定的大字符串的多少位前缀。类似于DP的思想,标记出结束位置。看最远结束在哪里。#include using namespace std;const int N = 1205;const int M = 200004;string ch.....
分类:
其他好文 时间:
2015-07-21 06:42:05
阅读次数:
94
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 le...
分类:
其他好文 时间:
2015-07-20 23:00:05
阅读次数:
85
DescriptionThere is a sequence of integers. Your task is to find the longest subsequence that satisfies the following condition: the difference betwee...
分类:
其他好文 时间:
2015-07-20 12:21:06
阅读次数:
82
【014-Longest Common Prefix(最长公共前缀)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Write a function to find the longest common prefix string amongst an array of strings.
题目大意 写一个函数找出一个字串所数组中的最长的公共前缀。
解题思路 第一...
分类:
编程语言 时间:
2015-07-20 09:18:51
阅读次数:
183
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-07-19 10:00:25
阅读次数:
125
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2015-07-18 21:14:22
阅读次数:
120
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-07-18 00:24:41
阅读次数:
147
这个也是简单题目,但是关键在于题意的理解。
题目原文就一句话:Write a function to find the longest common prefix string amongst an array of strings.
题意是给一个字符串数组,找出这个字符串数组中所有字符串的最长公共前缀。
注意是限定的前缀,而不是子串。...
分类:
其他好文 时间:
2015-07-17 22:53:11
阅读次数:
134
比较简单的DP,用记忆化搜索比较简单,递推。。。应该不好写吧 。
很容易发现,对于同一个位置,它的最长路是一定的, 不会变的,因为路是递减的,所以该题很适合用记忆化搜索 。 由此我们也可以发现DP和搜索的联系 。
代码如下:
#include
using namespace std;
int T,r,c,a[105][105],d[105][105];
int dx[] = {0,1,...
分类:
其他好文 时间:
2015-07-17 22:47:06
阅读次数:
122