Longest Common Subsequence
Source
https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_10_C
Description
Time Limit : 1 sec , Memory Limit : 131072 KB
Longest Common Subsequence
For given two sequences XX and YY, a sequence ZZ is a common subsequence of XX and YY if ZZ is a subsequence of both XX and YY. For example, if X={a,b,c,b,d,a,b}X={a,b,c,b,d,a,b} and Y={b,d,c,a,b,a}Y={b,d,c,a,b,a}, the sequence {b,c,a}{b,c,a} is a common subsequence of both XX and YY. On the other hand, the sequence {b,c,a}{b,c,a} is not a longest common subsequence (LCS) of XX and YY, since it has length 3 and the sequence {b,c,b,a}{b,c,b,a}, which is also common to both XX and YY, has length 4. The sequence {b,c,b,a}{b,c,b,a}is an LCS of XX and