Class Solution
java.lang.Object
g1401_1500.s1403_minimum_subsequence_in_non_increasing_order.Solution
1403 - Minimum Subsequence in Non-Increasing Order.<p>Easy</p>
<p>Given the array <code>nums</code>, obtain a subsequence of the array whose sum of elements is <strong>strictly greater</strong> than the sum of the non included elements in such subsequence.</p>
<p>If there are multiple solutions, return the subsequence with <strong>minimum size</strong> and if there still exist multiple solutions, return the subsequence with the <strong>maximum total sum</strong> of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.</p>
<p>Note that the solution with the given constraints is guaranteed to be <strong>unique</strong>. Also return the answer sorted in <strong>non-increasing</strong> order.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [4,3,10,9,8]</p>
<p><strong>Output:</strong> [10,9]</p>
<p><strong>Explanation:</strong> The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included, however, the subsequence [10,9] has the maximum total sum of its elements.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [4,4,7,6,7]</p>
<p><strong>Output:</strong> [7,7,6]</p>
<p><strong>Explanation:</strong> The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to returned in non-decreasing order.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [6]</p>
<p><strong>Output:</strong> [6]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 500</code></li>
<li><code>1 <= nums[i] <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minSubsequence
-