Hi everyone, I am trying to learn suffix arrays. How can I implement code of this algorithm ? I tried search it on google. But codes that I found are very complex. Please show me how can I code this.
I think you already know the brute force approach, which is to loop i from 0 to n-1 and store all substrings from i to n-1 in an array of strings and then just sort it. I don’t think its that hard to code and i think you were referring to the optimized approaches.
If you want it to be more efficient you will have to study a more complex approach. I personally haven’t studied suffix arrays, I just had a quick look at it. All i can tell you is to not be afraid of complex code. Everything seems hard before it becomes easy.
You can reffer to this website (suffix arrays from cp-algorithms.com )for more info. Its a very good website for competitive programming.
You are right fr. Thanks you.
This resources looks good : Suffix Array - Algorithms for Competitive Programming