Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ...
分类:
其他好文 时间:
2014-12-23 15:05:53
阅读次数:
174
Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there...
分类:
其他好文 时间:
2014-12-23 00:07:39
阅读次数:
142
Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there...
分类:
其他好文 时间:
2014-12-21 23:28:50
阅读次数:
224
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.Show TagsSOLUTION 1:解法很直观。先找到最小长度,然后逐个字母遍历,...
分类:
其他好文 时间:
2014-12-21 20:35:48
阅读次数:
189
题目:
Write a function to find the longest common prefix string amongst an array of strings.
第一种解决方案:
public class Solution {
public String longestCommonPrefix(String[] strs) {
int st...
分类:
其他好文 时间:
2014-12-20 23:32:55
阅读次数:
341
"trie的经典应用" -- by hzwer我们把每个点到根的xor值记下来,然后找出两个xor值最大的即可(因为(a ^ c) ^ (b ^ c) = a ^ b)于是用trie把每个数的二进制位记下来,每次query的时候利用贪心,试图走到另一个儿子即可。 1 /**************....
分类:
其他好文 时间:
2014-12-20 23:28:26
阅读次数:
362
Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4...
分类:
其他好文 时间:
2014-12-20 16:49:31
阅读次数:
178
题目
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.
解答
求二叉树的最大深度。
递归:a.若二叉树为空,...
分类:
其他好文 时间:
2014-12-20 15:38:37
阅读次数:
173
One TopCoder article introduces a very interesting alternative solution to Longest Common Sequences problem.It is based on this statement (http://comm...
分类:
其他好文 时间:
2014-12-20 10:26:37
阅读次数:
240
Write a function to find the longest common prefix string amongst an array of strings.
方法一,单个字符横向全体比较,纵向逐个的收集。
class Solution {
public:
string longestCommonPrefix(vector &strs) {
i...
分类:
其他好文 时间:
2014-12-19 15:48:20
阅读次数:
142