-3

I have a question in bioinformatics. You can solve it by suffix tree structure.

Given a string S=S[1…n] and a number k, we want to find the smallest sub-string of S that occurs in S exactly k times, if it exists. How to solve this problem in O(n) time?

1 Answers1

1

Build the suffix tree of the string O(N).

Count for every node the number of leafs under it O(N).

Find a node where the count == k. The path from the root to that node is a substring that repeats exactly k times.

Sorin
  • 11,863
  • 22
  • 26