leetcode
小小小picnic
这个作者很懒,什么都没留下…
展开
-
线性时间字符串匹配算法 - KMP
先引出KMP的概念,以下引用自wikipedia: 在计算机科学中,Knuth-Morris-Pratt 字符串搜索算法(或KMP算法)通过采用以下观察方法来搜索W主“文本字符串”中“单词”的S出现:出现不匹配时,单词本身就包含了足够的信息。确定下一个匹配项从何处开始,从而绕过对先前匹配的字符的重新检查。 … 这是第一个用于字符串匹配的线性时间算法。 场景:找出字符串s1中,字符串s2的出现位置。 例题:28. Implement strStr() Implement strStr().Return原创 2020-05-21 17:47:57 · 315 阅读 · 0 评论 -
leetcode-Permutation in String
Given two stringss1ands2, write a function to return true ifs2contains the permutation ofs1. In other words, one of the first string's permutations is thesubstringof the second string. Example 1: Input: s1 = "ab" s2 = "eidbaooo" Output: True...原创 2020-05-19 16:03:19 · 96 阅读 · 0 评论