• + 0 comments

    The DP idea works; its comlexity depends on how it's implemented.

    The main idea to accelerate O(n^2) into O(nlogn) is that, among the longest increasing subsequences (LIS) of same length so far, we need only care about the LIS that ends at the smallest value, as it has the most potential to expand. This enables an O(logn) time looking up for the LIS to expand.

    More details was found here: http://www.capacode.com/array/longest-increasing-subsequence-in-on-log-n-time/