diff --git a/src/other/temp.js b/src/other/temp.js new file mode 100644 index 0000000..ed3c9ed --- /dev/null +++ b/src/other/temp.js @@ -0,0 +1,18 @@ +// KMP 算法实例 +function kmpSearch(str, pattern) { + // 生成 next 数组 + function getNext(pattern) { + + } + + const next = getNext(pattern); + let i = 0; + let j = 0; + while (i < str.length && j < pattern.length) { + if (j === -1 || str[i] === pattern[j]) { + i++; + j++; + } + } + +} \ No newline at end of file