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-02-27 08:27:45
阅读次数:
153
No.14,Longest Common Prefix 这道题的输入是一个字符串数组,从里面找出最长的公共前缀。 解题思路:从第一个字符串和第二个字符串开始找寻最长公共前缀,再将最长公共前缀和第三个字符串比较,以此类推,遍历全部字符串,找出最后的公共前缀。 优化点在于,最长公共前缀的长度一定小于等于
分类:
其他好文 时间:
2016-02-26 21:55:53
阅读次数:
206
题目链接 先求每个点到根的异或和 然后就要找出两个点,使dis[a]^dis[b]最大 注意异或的性质,我们可以用trie树,沿着与当前数字每位的相反方向走 1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #inclu
分类:
其他好文 时间:
2016-02-26 09:13:09
阅读次数:
210
Give an integer array,find the longest increasing continuous subsequence in this array. An increasing continuous subsequence: Can be from right to lef
分类:
其他好文 时间:
2016-02-26 08:07:58
阅读次数:
144
Given a dictionary, find all of the longest words in the dictionary. Example Given { "dog", "google", "facebook", "internationalization", "blabla" } t
分类:
其他好文 时间:
2016-02-26 08:06:48
阅读次数:
172
package cn.edu.xidian.sselab.string;/** * * @author zhiyong wang * title: Longest Common Prefix * content: * *Write a function to find the longest com
分类:
其他好文 时间:
2016-02-25 22:45:08
阅读次数:
175
Binary Tree Longest Consecutive Sequence
分类:
其他好文 时间:
2016-02-25 01:36:25
阅读次数:
188
LCS - Longest Common Substring no tags A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the set of lower
分类:
其他好文 时间:
2016-02-25 00:04:38
阅读次数:
183
题意 n个数里,找到最长的一个连续序列使里面最多k个不同的数。 分析 尺取法,每次R++,如果第R个数未出现过,那么不同的数+1,然后这个数的出现次数+1,如果不同的数大于k了,那就要去掉第L个数,直到不同的数为k,然后更新答案。 代码 #include<cstdio> #define ll lon
分类:
其他好文 时间:
2016-02-24 15:38:48
阅读次数:
142
题目链接:https://leetcode.com/problems/longest-common-prefix/
题目:Write a function to find the longest common prefix string amongst an array of strings.
解题思路:寻找字符串数组的最长公共前缀,将数组的第一个元素作为默认公共前缀,依次与后面的元素进行比较...
分类:
其他好文 时间:
2016-02-24 09:43:09
阅读次数:
141