Блог пользователя swordx

Автор swordx, история, 7 лет назад, По-английски

Hello Guys,

Can you share your thoughts on the following question:

Given a string, we have to find the longest non-overlapping repeating subsequence. For example, If we have a string like "abdead", then here the answer is "ad" because longest repeating subsequence is "ad" which is non-overlapping.

My initial thought on this question is that we can use the concept of longest common subsequence but we need to manage the non-overlapping part.

Thanks in advance!

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

Split the string into two strings $$$s_1,s_2$$$ such that $$$s=s_1s_2$$$ in all possible ways (there are $$$n-1$$$ ways) and then find the LCS of those two strings. The largest such LCS is the solution. The complexity is $$$O(n^3)$$$. It can probably be done faster though.

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

For each suffix run z-algorithm. O(n^2) update: only works for segments