Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fee57af

Browse files
authored
Fix LCP Out-of-bound error (#841)
1 parent d5a6395 commit fee57af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/string/suffix-array.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ To do this, we compare the strings by power of twos (from highest to lowest powe
288288
int lcp(int i, int j) {
289289
int ans = 0;
290290
for (int k = log_n; k >= 0; k--) {
291-
if (c[k][i] == c[k][j]) {
291+
if (c[k][i % n] == c[k][j % n]) {
292292
ans += 1 << k;
293293
i += 1 << k;
294294
j += 1 << k;

0 commit comments

Comments
 (0)