Longest Increasing Subsequence

https://segmentfault.com/a/1190000003819886

 

Given a sequence of integers, find the longest ascending subsequence (LIS) and return the length of the LIS.

The example gives [5,4,1,2,3], the LIS is [1,2,3], returns 3

Given [4,2,4,5,3,7], this LIS is [4,4,5,7], return 4

The challenge requires a time complexity of O(n^2) or O(nlogn)

Explain the definition of the longest ascending subsequence:

The longest ascending subsequence problem is to find a subsequence arranged from low to high as long as possible in an unordered given sequence, and this subsequence is not necessarily contiguous or unique.
https://en.wikipedia.org/wiki/Longest_common_subsequence_problem

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326373731&siteId=291194637