Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". 查找一组字符 ...
分类:
其他好文 时间:
2018-12-02 22:47:30
阅读次数:
160
Given two sequences of characters, print the length of the longest common subsequence of both sequences. Sequence 1: &nb ...
分类:
其他好文 时间:
2018-12-02 19:20:57
阅读次数:
225
树结构问题因为容易写出解法,因此经常出现在面试题中 1. 树的种类 1) Tree 2) Binary Trees 3) Binary Search Trees(BST) : used to sorted or ordered data. //解决方案:recursion 查找操作(fast and ...
分类:
其他好文 时间:
2018-12-01 18:40:43
阅读次数:
191
Longest Common Subsequence "Aizu ALDS1_10_C" For given two sequences X and Y, a sequence Z is a common subsequence of X and Y if Z is a subsequence of ...
分类:
其他好文 时间:
2018-12-01 11:12:55
阅读次数:
194
题意: 求最长增长的子序列的长度。 思路: 利用DP存取以i作为最大点的子序列长度。 Runtime: 20 ms, faster than 35.21% of C++ online submissions for Longest Increasing Subsequence. 解法二: 讨论区里的 ...
分类:
其他好文 时间:
2018-11-29 15:04:45
阅读次数:
159
题意:求一个字符串的最长不含重复字符的子字符串长度; 示例: input:pwwkw output:2 intput:dvdf output:3 分析:还是那句话,每分析一个问题的时候都要问自己,自己的大脑是如何找出正确答案的,将自己的分析转化为代码此题便解 题目要求不含重复字符,且是子字符串; 1 ...
分类:
其他好文 时间:
2018-11-28 00:29:14
阅读次数:
190
2018-11-25 16:28:09 问题描述: 问题求解: 方法一、如果不要求是线性时间的话,其实可以很直观的先排序在遍历一遍就可以得到答案,但是这里明确要求是O(n)的时间复杂度,那么就给了一个强烈的提示就是使用Hash来进行解决。方法一的思路很明确也很暴力,就是将所有的数字都保存到一个Has ...
分类:
其他好文 时间:
2018-11-26 02:18:42
阅读次数:
184
8ms,47.18%. 结合最快方法改进: 有时4ms,99.91%,有时8ms。。可以了。 ...
分类:
其他好文 时间:
2018-11-25 20:13:50
阅读次数:
202
多串LCS~~很适合SA但是我要学SAM~~ 对第一个串求SAM,然后把剩下的串在SAM上跑,也就是维护p和len,到一个点,如果有ch[p][c],就p=ch[p][c],len++,否则向fa找最下的有c[p][c]的p,然后len=dis[p]+1,p=ch[p][c],否则就p=root,l ...
分类:
其他好文 时间:
2018-11-23 10:11:27
阅读次数:
174