码迷,mamicode.com
首页 >  
搜索关键字:longest    ( 2697个结果
【LeetCode】 Maximum Depth of Binary Tree
题目 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-10-25 18:50:01    阅读次数:137
[LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)
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-10-25 07:04:13    阅读次数:208
[LeetCode] Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.题目言简意赅,貌似也不难,暴力法用一个char *数组存放strs里每个元素的起始地址,然后循环,同时把所有指针向前移动,如果有...
分类:其他好文   时间:2014-10-25 00:52:44    阅读次数:265
[LeetCode] Longest Consecutive Sequence
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
LeetCode:Maximum Depth of Binary Tree
题目描述: 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
UVa 10100 - Longest Match
题目:求两组字符串中最大的按顺序出现的相同单词数目。 分析: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
leetcode第31题--Longest Valid Parentheses
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
Longest Common Prefix
给出的是一个字符串数组,然后去求这些字符串的最长公共前缀,挺有意思的一道题目。public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length==0||strs[0...
分类:其他好文   时间:2014-10-22 23:32:33    阅读次数:270
Leetcode | Longest Common Prefix
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
Maximum Depth of Binary Tree 二叉树的深度
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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!