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 l ...
分类:
其他好文 时间:
2016-04-20 21:35:38
阅读次数:
146
题意为给出一个字符串,找出其中没有重复字符的最长子序列的长度。brute force的复杂度为O(n^3).依次查找每个子字符串是否含有重复字符,并比较长度。开始看到题目,想用DP解决,在已有目前最长子序列的情况下,比较把当前字符串放入和不放入,那个子序列长度会更大,但是这种解法的复杂度为O(n^2 ...
分类:
其他好文 时间:
2016-04-19 00:09:11
阅读次数:
127
Write a function to find the longest common prefix string amongst an array of strings. []=>""["abcweed","htgdabc","sabcrf"]=>""["abcweed","abhtgdc","a ...
分类:
其他好文 时间:
2016-04-18 11:38:56
阅读次数:
129
3-1.LIS(longest increas sequence)不多说,题目说了要($ O(n^2) $),我还能说什么呢? 相同题目:HDU 1087 super jumping !jumping!jumping! 而且不卡平方的做法 用dp[i]表示以 i 个数结尾的序列的LIS长度,初始化为 ...
分类:
编程语言 时间:
2016-04-18 10:12:54
阅读次数:
284
Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. Example For "ABCD" and "EDCA", the LCS is "A" ...
分类:
其他好文 时间:
2016-04-18 08:43:52
阅读次数:
117
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng ...
分类:
其他好文 时间:
2016-04-17 11:37:10
阅读次数:
158
刷leetcode,看到一个算法,给大神跪了。。。。看了半天才明白,下面谈谈理解 这道题最朴素的想法,就是两层遍历: 1、第一层遍历所有字符,表示以每一位置的字符打头的子串; 2、第二层,以某一位置字符开头,向后遍历,可以用map容器插入操作判断是否有重复字符,并计算长度; 3、这样做的话,实际上是 ...
分类:
其他好文 时间:
2016-04-15 21:54:33
阅读次数:
233
Write a function to find the longest common prefix string amongst an array of strings. ...
分类:
其他好文 时间:
2016-04-13 20:22:35
阅读次数:
229
I caught the sparkle in my mind and got AC1 ! It is a great great experience ! So the basic idea: permute on 3 consecutive items doesn't change the pa ...
分类:
其他好文 时间:
2016-04-13 07:11:01
阅读次数:
274