Longest common subsequence problem with a solution