Find the longest increment sequence O (NLOGN) (not necessarily continuous!)
Reference http://www.felix021.com/blog/read.php?1587%E5%8F%AF%E6%98%AF%E8%BF%9E%E6%95%B0%E7%BB%84%E9%83%BD%E6%B2%A1%E7 %bb%99%e5%87%ba%e6%9d%a5
I just understood his analysis in a more understandable sense.
The title is this d[1..9] = 2 1 5 3 6 4 8 9 7 requires the longest increment subsequence to be found
First, using an array of b[] in order to drop the elements in D into B is used to record the current maximum increment of the subsequence
Throw in 2 to B first
[2] At this time, in the case of an element 2 is known, the longest increment of the subsequence is [2]
Throw in 1
[2 1] found at this time the longest increment of the subsequence is 1 because 2 1 does not constitute an increment
and delete the element that is smaller than the new element added is delete 2
So again [1].
Throw in 5
[1 5]
Throw in 3
[1 5 3] Again there is no increment of the situation said B is used to record the current element increment sub-sequence so b inside should be increment only to
Delete the element that is smaller than the new element added is 5 get [1 3]----at this time the increment subsequence length is 2
Throw in 6
[1 3 6]
Throw in 4
[1 3 6 4]---> [1 3 4]----length 3
Throw in 8
[1 3 4 8]----Length 4
Throw in 9
[1 3 4 8 9]----Length 5
Throw in 7
[1 3 4 8 9 7]----> [1 3 4 7]---length 4
Then the maximum increment subsequence has been found 1 3 4 8 9
The longest increment subsequence of the algorithm surface question LIS