Skip to content

Commit cce921e

Browse files
committed
fix bug
1 parent ca8633b commit cce921e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Classical algorithm problem/Boyer-Moore.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
j--
3030
} else {
3131
lastIndex = badSuffix[text.charAt(i)] >= 0 ? badSuffix[text.charAt(i)] : -1;
32-
i += pLen - 1 - j + Math.max(j - lastIndex, goodSuffix[j]);
32+
i += pLen - 1 - j + Math.max(j - lastIndex, goodSuffix[j])
3333
j = pLen - 1;
3434
}
3535
}
@@ -38,7 +38,7 @@
3838

3939

4040
let computeBadSuffix = function () {
41-
for (let j = pLen - 1; j >= 0; j--) {
41+
for (let j = 0; j < pLen - 1; j++) {
4242
badSuffix[pattern.charAt(j)] = j
4343
}
4444
};
@@ -84,7 +84,8 @@
8484
match()
8585
}
8686

87-
BoyerMoore("here is a simple example", "example")
87+
BoyerMoore("here is a simple slexample", "slexample")
88+
// BoyerMoore("abbadcababacab", "babac")
8889
</script>
8990
</body>
9091
</html>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy