From 2568258f28466e98d65f9b6f3a792f92d9feab17 Mon Sep 17 00:00:00 2001 From: chenshuai <2268380485@qq.com> Date: Thu, 13 Mar 2025 21:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=80=A7=E6=8F=90=E4=BA=A4:?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E8=A1=8C=E6=95=B0=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E7=9A=84=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/other/temp.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/other/temp.js 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