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-11-13 07:49:37
阅读次数:
170
Description Given two strings, you have to tell the length of the Longest Common Substring of them. For example: str1 = banana str2 = cianaic So the L ...
分类:
编程语言 时间:
2016-11-10 02:09:11
阅读次数:
233
这道题是让求最长回文字符解法有三 1.暴力解法 时间复杂度O(n3) 代码: 解法二 从字符中间向两边蔓延 时间复杂度o(n2) 代码: 解法三 动态规划 主要是设置一个二维数组,长度均为字符串长度,然后已经检测的设置为true,这样就免去了重复检测已检测的字符 时间复杂度o(n2) 代码: 还有一 ...
分类:
其他好文 时间:
2016-11-09 11:01:42
阅读次数:
186
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-11-05 17:28:13
阅读次数:
147
注意最长公共子串(Longest CommonSubstring)和最长公共子序列(LongestCommon Subsequence, LCS)的区别:子串(Substring)是串的一个连续的部分,子序列(Subsequence)则是从不改变序列的顺序,而从序列中去掉任意的元素而获得的新序列;更 ...
分类:
其他好文 时间:
2016-11-04 14:24:17
阅读次数:
200
Problem: 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 f ...
分类:
其他好文 时间:
2016-11-03 09:30:34
阅读次数:
171
Write a function to find the longest common prefix string amongst an array of strings. 思路:要去是寻找字符串vector里最长的公有前缀。 1。构造迭代器,遍历vector搜索最小string长度。然后从第一个字 ...
分类:
其他好文 时间:
2016-11-02 23:04:01
阅读次数:
125
这周前面刷题倒是蛮开心,后面出了很多别的事情和问题就去忙其他的,结果又只完成了最低目标。 Lonest Substring Without Repeating Characters: Given a string, find the length of the longest substring w ...
分类:
其他好文 时间:
2016-10-31 07:12:43
阅读次数:
209
二分查找的一个经典例子 非递减数列的二分查找 这个题,看起来很简单,可是仔细一看是含有重复值的非递减数组,那这个时候碰到target这个数字的时候就不能立刻返回了,那么这个时候需要继续在左半部分找更早出现的target。这个时候让end=mid-1, 并且把终止条件变成start<=end,这样如果 ...
分类:
其他好文 时间:
2016-10-31 06:58:36
阅读次数:
173