http://qs321.pair.com?node_id=543621

TedPride has asked for the wisdom of the Perl Monks concerning the following question:

Your job, should you choose to accept it, is to come up with an algorithm to find the longest increasing sequence of numbers in a given array in O(n lg n) time. For instance:

A = {8, 6, 5, 1, 9, 3, 7, 4, 2, 10}
Longest increasing sequence = {1, 3, 4, 10}

A = {3, 10, 6, 1, 5, 7, 8, 2, 4, 9}
Longest increasing sequence = {1, 5, 7, 8, 9}

If more than one longest sequence is possible, any of the available longest sequences may be returned.

Have fun!