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
LCS Longest Common Substring Description 给两个长度$\le 250000$的小写字母串, 求最长公共子串. Solution 子串就是SAM了. 对其中一个建出SAM, 另一个在上面跑, 如果可以转移, 就直接转移, 长度加一, 否则跳父亲到可以转移, 自然 ...
分类:
其他好文 时间:
2018-11-22 00:31:01
阅读次数:
251
先看一下题目描述: 先默认strs[0]是最长公共前缀prefix,然后通过indexOf判断是prefix是否从strs[1]0索引开始,如果不是,则通过substring函数减少一位,直到从0索引开始。时间复杂度为O(N)。 ...
分类:
其他好文 时间:
2018-11-21 16:07:07
阅读次数:
204
1. Question: url : https://leetcode.com/problems/longest-continuous-increasing-subsequence/ 674. Longest Continuous Increasing Subsequence Given an un ...
分类:
其他好文 时间:
2018-11-19 22:09:44
阅读次数:
148
https://leetcode.com/problems/longest-palindromic-substring/ Given a string s, find the longest palindromic substring in s. You may assume that the ma ...
分类:
其他好文 时间:
2018-11-19 15:07:40
阅读次数:
186
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This ...
分类:
其他好文 时间:
2018-11-16 17:43:50
阅读次数:
116
https://leetcode.com/tag/union-find/ ...
分类:
其他好文 时间:
2018-11-15 17:07:47
阅读次数:
253
1.翻转字符串算法 1 function reverseString(str) { 2 var res=str.split("").reverse().join(""); 3 return res; 4 } 5 reverseString("hello"); 2.阶乘算法 1 function fa ...
分类:
编程语言 时间:
2018-11-15 00:08:48
阅读次数:
231
Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, a ...
分类:
其他好文 时间:
2018-11-13 18:04:10
阅读次数:
155