Longest Common Sequence Algorithm