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

Skip to content

Conversation

donaldong
Copy link
Contributor

@donaldong donaldong commented May 10, 2022

This PR is to fix #815

@donaldong donaldong mentioned this pull request May 10, 2022
@adamant-pwn
Copy link
Member

Hi, thanks for the fix! But are you sure this is the correct way to address the issue? The article describes a suffix array on the looped string (that is, it sorts cyclic shifts of the string rather than its suffixes). With this in mind, shouldn't we instead take i and j modulo n after additions? So, instead of adding i < n && j < n check we would do c[k][i % n] == c[k][j % n] check inside the loop?

@adamant-pwn
Copy link
Member

By the way, i < n && j < n doesn't seem to be a valid break condition for non-cyclic string, as it can provide an answer which is larger than it should be.

@donaldong
Copy link
Contributor Author

Yes, you're absolute right. Checking for i < n && j < n does not really make sense outside of that particular coding problem was working on. Thanks for noticing and pointing that out!

@adamant-pwn
Copy link
Member

Thanks for the quick fix! Merging it now.

@adamant-pwn adamant-pwn merged commit fee57af into cp-algorithms:master May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LCP Out-of-bound error
2 participants