|
| 1 | +# 3678. Smallest Absent Positive Greater Than Average |
| 2 | + |
| 3 | +<p>You are given an integer array <code>nums</code>.</p> |
| 4 | + |
| 5 | +<p>Return the <strong>smallest absent positive</strong> integer in <code>nums</code> such that it is <strong>strictly greater</strong> than the <strong>average</strong> of all elements in <code>nums</code>.</p> |
| 6 | +The <strong>average</strong> of an array is defined as the sum of all its elements divided by the number of elements. |
| 7 | +<p> </p> |
| 8 | +<p><strong class="example">Example 1:</strong></p> |
| 9 | + |
| 10 | +<div class="example-block"> |
| 11 | +<p><strong>Input:</strong> <span class="example-io">nums = [3,5]</span></p> |
| 12 | + |
| 13 | +<p><strong>Output:</strong> <span class="example-io">6</span></p> |
| 14 | + |
| 15 | +<p><strong>Explanation:</strong></p> |
| 16 | + |
| 17 | +<ul> |
| 18 | + <li>The average of <code>nums</code> is <code>(3 + 5) / 2 = 8 / 2 = 4</code>.</li> |
| 19 | + <li>The smallest absent positive integer greater than 4 is 6.</li> |
| 20 | +</ul> |
| 21 | +</div> |
| 22 | + |
| 23 | +<p><strong class="example">Example 2:</strong></p> |
| 24 | + |
| 25 | +<div class="example-block"> |
| 26 | +<p><strong>Input:</strong> <span class="example-io">nums = [-1,1,2]</span></p> |
| 27 | + |
| 28 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 29 | + |
| 30 | +<p><strong>Explanation:</strong></p> |
| 31 | + |
| 32 | +<ul> |
| 33 | + <li>The average of <code>nums</code> is <code>(-1 + 1 + 2) / 3 = 2 / 3 = 0.667</code>.</li> |
| 34 | + <li>The smallest absent positive integer greater than 0.667 is 3.</li> |
| 35 | +</ul> |
| 36 | +</div> |
| 37 | + |
| 38 | +<p><strong class="example">Example 3:</strong></p> |
| 39 | + |
| 40 | +<div class="example-block"> |
| 41 | +<p><strong>Input:</strong> <span class="example-io">nums = [4,-1]</span></p> |
| 42 | + |
| 43 | +<p><strong>Output:</strong> <span class="example-io">2</span></p> |
| 44 | + |
| 45 | +<p><strong>Explanation:</strong></p> |
| 46 | + |
| 47 | +<ul> |
| 48 | + <li>The average of <code>nums</code> is <code>(4 + (-1)) / 2 = 3 / 2 = 1.50</code>.</li> |
| 49 | + <li>The smallest absent positive integer greater than 1.50 is 2.</li> |
| 50 | +</ul> |
| 51 | +</div> |
| 52 | + |
| 53 | +<p> </p> |
| 54 | +<p><strong>Constraints:</strong></p> |
| 55 | + |
| 56 | +<ul> |
| 57 | + <li><code>1 <= nums.length <= 100</code></li> |
| 58 | + <li><code>-100 <= nums[i] <= 100</code></li> |
| 59 | +</ul> |
0 commit comments