'Longest increasing subsequence with minimum sum
I know there is a longest increasing subsequence algorithm that runs in O(nlogn) (https://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/), but what if there are multiple increasing subsequences of the same length and I want to take the one with the minimum sum? Is there a way to calculate this, in O(nlogn) as well? I have found one that does it, but in (n^2) (https://www.geeksforgeeks.org/maximize-sum-of-all-elements-which-are-not-a-part-of-the-longest-increasing-subsequence/).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|