algorithm: longest common subsequence works