Skip to content

Commit d8b28f3

Browse files
committed
working commit - Created using LeetHub
1 parent faf94bf commit d8b28f3

File tree

1 file changed

+34
-0
lines changed
  • minimum-subsequence-in-non-increasing-order

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<h2>unknown-problem</h2><h3>Easy</h3><hr><div><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&nbsp;included elements in such subsequence.&nbsp;</p>
2+
3+
<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.&nbsp;</p>
4+
5+
<p>Note that the solution with the given constraints is guaranteed to be&nbsp;<strong>unique</strong>. Also return the answer sorted in <strong>non-increasing</strong> order.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong>Example 1:</strong></p>
9+
10+
<pre><strong>Input:</strong> nums = [4,3,10,9,8]
11+
<strong>Output:</strong> [10,9]
12+
<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.&nbsp;
13+
</pre>
14+
15+
<p><strong>Example 2:</strong></p>
16+
17+
<pre><strong>Input:</strong> nums = [4,4,7,6,7]
18+
<strong>Output:</strong> [7,7,6]
19+
<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.
20+
</pre>
21+
22+
<p><strong>Example 3:</strong></p>
23+
24+
<pre><strong>Input:</strong> nums = [6]
25+
<strong>Output:</strong> [6]
26+
</pre>
27+
28+
<p>&nbsp;</p>
29+
<p><strong>Constraints:</strong></p>
30+
31+
<ul>
32+
<li><code>1 &lt;= nums.length &lt;= 500</code></li>
33+
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
34+
</ul></div>

0 commit comments

Comments
 (0)