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 consists of 2 integers i and j such that 0 <= i,j <= n - 1. For each such query, I want to find 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^3
Time Limit: 3 seconds