viralm's blog

By viralm, history, 6 years ago, In English
I am trying to solve a problem where I am given 2 strings A and B. Length of A is n and length of B is m. Now, q queries need to be answered. Each query will consist of 2 integers i and j such that 1 <= i,j <= n. For each such query, I want to find the length of the longest common sub-sequence of A.sub_string(i, j) and B.
Constraints:
1 <= n <= 10^4
1 <= m <= 10^4
1 <= Q <= 10^2

Time Limit: 3 seconds
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
6 years ago, # |
Rev. 2   Vote: I like it -29 Vote: I do not like it

LCS works in O(nm), with Q queries it will be O(Qnm).