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

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

given a string S. you have to find maximum product of length of two non overlapping palindromic sequence.
here, non overlapping means only indexes are non overlap.

for example,

1)
s = “abcab”
ans = 3*2 = 6
two palindromic sequence are “aca” and “bb”

2 )
s = nriatdoiarn
ans = 5*5 = 25
two palindromic sequences are “nitin” and ( “radar” or “raoar”)

3 )
s = “abcdef”
ans = 1*1 = 1

please share your solution.

Easy Version link : https://stackoverflow.com/questions/53663721/find-the-maximum-product-of-two-non-overlapping-palindromic-subsequences

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

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

[Deleted]

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

Please, someone answer it. This appears to be a very good question to me.

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

stackexchange code is wrong

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

Wrong idea

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

What about the stack exchange answer. It looks correct to me, and is $$$O(n^{2})$$$. Please point out if something is wrong.

So another question is, for $$$A$$$ and $$$B$$$ to be non overlapping subsequences of given string $$$S$$$, what is the exact criteria?

Since $$$A$$$ = $$$S[i_1]$$$,$$$S[i_2]$$$, ... , $$$S[i_{n1}]$$$, and $$$B$$$ = $$$S[j_1]$$$,$$$S[j_2]$$$, ... , $$$S[j_{n2}]$$$ so which of the following do we want: ( assuming $$$i_1$$$ < $$$j_1$$$ )

$$$1)$$$ $$$i_{n1} \lt j_1$$$ ( basically for some string, "abcdefg" if I take $$$A$$$ = "ace" then can I only take letters after 'e' for $$$B$$$? )

OR

$$$2)$$$ $$$i_x != j_y$$$ for each $$$x$$$ in $$$range(1,n1)$$$ ,$$$y$$$ in $$$range(1,n2)$$$. ( no two characters of the same index )

I believe the stack exchange answer is definitely valid, in case of definition $$$1)$$$ of non overlapping subsequences.

UPD: I guess the example $$$2$$$ given in the post, makes it clear that the $$$2)$$$ definition is the one to be used.

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

Wrong idea, misread the problem statement.