humblefoolboi's blog

By humblefoolboi, history, 4 years ago, In English

I was trying a problem on LCS topic and was stuck. It will be really helpful if anyone can provide me a hint to the problem.

Problem :-ADASEED

  • Vote: I like it
  • +5
  • Vote: I do not like it

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

Auto comment: topic has been updated by humblefoolboi (previous revision, new revision, compare).

»
4 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Hello Chauhan saab

$$$ \frac{N}{L} \le 100$$$ suggests that we can try out the pairing of same colors as they are fewer.

One solution would be to first make all pairs of same color (with pair I mean we want them at same position in our last sequence). If we want $$$x$$$ and $$$y$$$ to be at same position, then $$$\forall\ i$$$ where $$$ min (x, y) \le i\ \le max (x, y)$$$, $$$A_{i}$$$ and $$$B_{i}$$$ must be choped (supposing A and B the given two array). This would mean after forming all pair we should select some such that they don't overlap (while of course maximizing length) but probably it will TLE if we select literally all pairs.

For any index $$$i$$$ if we try finding other index $$$j$$$ from other array such that $$$i \le j$$$, I don't think it makes sense to try more than one as the smallest such $$$j$$$ should be better than rest surely so therefore we don't take all the pairs one for each (as a starting) from both arrays this might make it in time but not sure enough.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Just realized second part is pure crap. I does make sense to try more than one.