From db57411ca1965fd605cff1bed334f83afbf4f50c Mon Sep 17 00:00:00 2001 From: ehlxr Date: Sun, 13 Mar 2022 16:26:12 +0800 Subject: [PATCH] kmp --- .../src/main/java/io/github/ehlxr/algorithm/match/Kmp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/budd-common/src/main/java/io/github/ehlxr/algorithm/match/Kmp.java b/budd-common/src/main/java/io/github/ehlxr/algorithm/match/Kmp.java index ef29c94..f1b3416 100644 --- a/budd-common/src/main/java/io/github/ehlxr/algorithm/match/Kmp.java +++ b/budd-common/src/main/java/io/github/ehlxr/algorithm/match/Kmp.java @@ -59,7 +59,7 @@ public class Kmp { } else { // 当模式串与主串不匹配时,如果**不匹配字符**对应模式串下标大于 j > 0 (非首个模式串字符), // 并且此字符前一个字符对应字符串部分匹配表中的值 next[j - 1] 也大于 0, - // 模式串后移到 next[j - 1] 位置 + // j - next[j - 1] 即模式串为后移的位数,等价于 j 置为 next[j - 1] if (j > 0 && next[j - 1] > 0) { j = next[j - 1]; } else {