shinghalrishabh's blog

By shinghalrishabh, history, 11 years ago, In English

How to find all occurences of each substring in the given string.Please give me some suggestions

  • Vote: I like it
  • -10
  • Vote: I do not like it

| Write comment?
»
11 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

you can easily make that in O(N*N*N) time using Brute force. Then using hashes it can be reduced to O(N*N). You cAn make that in O(N*N) using KMP.

»
11 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Z-Function.

»
11 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

If I understood the problem correctly, then using suffix array + lcp should give performance between O(N) and depending on chosen algorithm for searching suffix array.