Dynamic Programming, Longest Increasing Subsequence.