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 ...
分类:
其他好文 时间:
2014-10-24 23:30:05
阅读次数:
260
题目描述:
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.
解题思路:直接DFS。
代码:
/**...
分类:
其他好文 时间:
2014-10-24 13:04:21
阅读次数:
147
题目:求两组字符串中最大的按顺序出现的相同单词数目。
分析:dp,最大公共子序列(LCS)。把单词整个看成一个元素比较即可。
状态:f(i,j)为s1串前i个单词与s2串前j个单词的最大匹配数;
转移:f(i,j)= max(f(i-1,j),f(i,j-1)){ s1[i] ≠ s2[j] };
...
分类:
其他好文 时间:
2014-10-23 16:17:30
阅读次数:
183
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2014-10-22 23:32:51
阅读次数:
235
给出的是一个字符串数组,然后去求这些字符串的最长公共前缀,挺有意思的一道题目。public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length==0||strs[0...
分类:
其他好文 时间:
2014-10-22 23:32:33
阅读次数:
270
Write a function to find the longest common prefix string amongst an array of strings. 1 class Solution { 2 public: 3 string longestCommonPrefix(v...
分类:
其他好文 时间:
2014-10-22 17:30:53
阅读次数:
228
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 lea...
分类:
其他好文 时间:
2014-10-21 22:58:39
阅读次数:
235
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters...
分类:
其他好文 时间:
2014-10-20 21:11:05
阅读次数:
203
Longest Ordered SubsequenceTime Limit: 2000msMemory Limit: 65536KBThis problem will be judged onPKU. Original ID:253364-bit integer IO format:%lld Jav...
分类:
其他好文 时间:
2014-10-20 11:28:21
阅读次数:
174
Language:
Default
Longest Ordered Subsequence
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 33986
Accepted: 14892
Description
A numeric sequence of a...
分类:
其他好文 时间:
2014-10-19 11:38:30
阅读次数:
249