added optimal longest increasing subsequence O(nlgn) complexity