Longest common subsequence and longest increasing subsequence