Dr. Sannchita Sethi :P

0

0 votes
Problem

Dr. Sannchita is one of the best doctors in the world. For now, she's working on DNA sequences. She published in one of her research paper that using some mathematics and science, we can transform DNA sequence of one person to another if and only if it matches upto some percentage depending on the age of the person. As she's a hardworking girl, she's working on the cloning part but to save some time, she needs some help from you. Tell her the length of longest common sub sequence, so that she does not have to waste time on cloning if it is not above a certain percentage.

INPUT

First line has one integer T, number of testcases and each testcase contains N -> length of DNA sequence. first line contain N integers representing one DNA sequence. second line contain N integers representing second DNA sequence.

OUTPUT

For each testcase, output length of LCS of both DNA sequence.

NOTE:

All numbers in DNA sequence will be distinct.

CONSTRAINTS:

1<=T<=20
1<=N<= 10^5
1<=A[i] <= 1000000000 (10^9) for 1<=i<=N

HINT: Want a hint , check this Hint

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?