admin管理员组文章数量:1123567
It is a famous question which asked about finding longest nondecreasing subsequence from a given array. The question is well studied and have O(n log n) time complexity solutions.
I have encountered a slightly different question: Given an array with at least 2 elements. Find TWO nondecreasing subsequences from it. These two subsequences should not share same array elements (same by index, not same by value). And I want to maximum and output the sum of lengths.
A simple DP solution could be done in O(n^4). And maybe some optimize may be done to make it works better while I don't know. So the first question is about:
- What algorithm could we have to solve this question with best time complexity.
Another trivial idea is find the longest nondecreasing subsequence and remove it from original array, then repeat the finding again. This could be done in O(n log n). But I have no idea about:
- Is greedy solution correct? If so, how to prove or argue it. If not, how to find out counterexample.
- If not, can it serve as a valid approximation algorithm with some performance guarantees?
本文标签: algorithmMaximum the sum of lengths of two nondecreasing subsequence of given arrayStack Overflow
版权声明:本文标题:algorithm - Maximum the sum of lengths of two nondecreasing subsequence of given array - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736577408a1944887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论