Compare items in two sequences to find a longest common subsequence