Write a program that is as low in complexity as possible, and find the longest increment of the length of a subsequence in a one-dimensional array (n elements).
Solution One: Use dynamic programming to find out the maximum increment subsequence length at the end of the current element. Dp[i+1] = Max{1, dp[i]+1}, Array[i+1]>array[k],k<=i; The complexity is O (N*n + N).
Solution Two: Open an array to save the length of the increment sub-sequence of the maximum length of the last element of the smallest value, and then when the first element of the array is processed, the length of the current maximum subsequence starts to decrement, and then search until Arrary[i] is greater than the current maximum subsequence length of the end element value, Then update the length of the subsequence at the end of the first element. If the current longest sequence is greater than the longest increment sequence length, update the longest information, otherwise see if you want to update because Array[i] is added so that the elements at the end of the same length of the end element with Array[i] are the lowest element value. The complexity of this method is still O (n*n).
Solution three: Because in the increment sequence, if the i<j, then the length of the subsequence of the end element value must be less than the length of the end of J element value. Therefore, for finding the value of the end element until Arrary[i] is greater than the current maximum subsequence length, the idea of dichotomy can be taken, and the complexity is reduced to O (N*logn).
The beauty of programming---to find the longest increment subsequence in an array