You are given a permutation of $n$. Build an undirected graph of $n$ nodes. There is an edge $(i,j)$ if and only if $i<j$ and $p_i < p_j$. Please find the maximum matching of the graph.↵
↵
I don't know how to do it in $O(n \log n)$.
↵
I don't know how to do it in $O(n \log n)$.