We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca8633b commit cce921eCopy full SHA for cce921e
Classical algorithm problem/Boyer-Moore.html
@@ -29,7 +29,7 @@
29
j--
30
} else {
31
lastIndex = badSuffix[text.charAt(i)] >= 0 ? badSuffix[text.charAt(i)] : -1;
32
- i += pLen - 1 - j + Math.max(j - lastIndex, goodSuffix[j]);
+ i += pLen - 1 - j + Math.max(j - lastIndex, goodSuffix[j])
33
j = pLen - 1;
34
}
35
@@ -38,7 +38,7 @@
38
39
40
let computeBadSuffix = function () {
41
- for (let j = pLen - 1; j >= 0; j--) {
+ for (let j = 0; j < pLen - 1; j++) {
42
badSuffix[pattern.charAt(j)] = j
43
44
};
@@ -84,7 +84,8 @@
84
match()
85
86
87
- BoyerMoore("here is a simple example", "example")
+ BoyerMoore("here is a simple slexample", "slexample")
88
+ // BoyerMoore("abbadcababacab", "babac")
89
</script>
90
</body>
91
</html>
0 commit comments