Longest Increasing Subsequence
DPIntroduction LIS (Longest Increasing Subsequence) is a classic problem in dynamic programming. The problem is to find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order.
The subsequence is not necessarily contiguous or unique. The length of the subsequence is the number of elements in it.
For example:
Input: [10, 9, 2, 5, 3, 7, 101, 18] Output: 4 Explanation: The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4.
Read more...