Construction of Longest Monotonically Increasing Subsequence (N log N) - GeeksforGeeks
In my previous post, I have explained about longest monotonically increasing sub-sequence (LIS) problem in detail. However, the post only covered code related to querying size of LIS, but not the construction of LIS. I left it as an exercise. If you have solved, cheers. If not, you are not alone, here is code.
If you have not read my previous post, read here. Note that the below code prints LIS in reverse order. We can modify print order using a stack (explicit or system stack). I am leaving explanation as an exercise (easy).
Read full article from Construction of Longest Monotonically Increasing Subsequence (N log N) - GeeksforGeeks
No comments:
Post a Comment