Longest increasing subsequence problem