KMP
文章平均质量分 61
小榕流光
这个作者很懒,什么都没留下…
展开
-
[leetcode] 214. Shortest Palindrome 解题报告
题目链接:https://leetcode.com/problems/shortest-palindrome/Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrom原创 2016-06-12 04:21:16 · 4503 阅读 · 1 评论 -
统计字符流中一个字符串出现的次数- KMP算法
这是google onsite的一个题目, 说是一个无限的0/1字符串流, 给定一个字符串如"110010", 求到当前为止, 在字符流中出现了多少次这种字符.一开始想到dp来做, 然后画了一下转移方程感觉不对, 然后又感觉越看越像是KMP, 仔细分析可以发现, 其思路就是求当前字符流的后缀与给定的字符串相等即可. 按照正常的思路即取与给定字符串长度相等的字符串, 比较是否相等即可, 这种方式原创 2016-08-28 07:10:21 · 2655 阅读 · 0 评论 -
[leetcode] 28. Implement strStr() 解题报告
题目链接:https://leetcode.com/problems/implement-strstr/Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思路:很简单的一题,原创 2015-12-28 16:32:40 · 1072 阅读 · 0 评论