Implementation and test of longest common subsequence