Given a string S, I want to calculate number of substrings which occurred n times (1 <= n <= s.length()). I have done it with rolling hash, it can be done by using a suffix tree. How can it be solved using a suffix array in complexity O( n^2 ) ?
like for s = "ababaab"
n no.of string
4 1 "a" ( substring "a" is present 4 times)
3 2 "b" , "ab" (substring "b" and "ab" are present 3 times)
2 2 "ba" , "aba"
1 14 "aa" , "bab" , "baa" , "aab" , "abab" ....
This is not a forum to get free code, but since I was in such good mod this evning, i wrote a short example for you. But i cannot guarantee that is error free, this was written in 15 minutes without special much thoughts.
}