|
| 1 | +<h2><a href="https://leetcode.com/problems/kids-with-the-greatest-number-of-candies">1431. Kids With the Greatest Number of Candies</a></h2><h3>Easy</h3><hr><p>There are <code>n</code> kids with candies. You are given an integer array <code>candies</code>, where each <code>candies[i]</code> represents the number of candies the <code>i<sup>th</sup></code> kid has, and an integer <code>extraCandies</code>, denoting the number of extra candies that you have.</p> |
| 2 | + |
| 3 | +<p>Return <em>a boolean array </em><code>result</code><em> of length </em><code>n</code><em>, where </em><code>result[i]</code><em> is </em><code>true</code><em> if, after giving the </em><code>i<sup>th</sup></code><em> kid all the </em><code>extraCandies</code><em>, they will have the <strong>greatest</strong> number of candies among all the kids</em><em>, or </em><code>false</code><em> otherwise</em>.</p> |
| 4 | + |
| 5 | +<p>Note that <strong>multiple</strong> kids can have the <strong>greatest</strong> number of candies.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strong class="example">Example 1:</strong></p> |
| 9 | + |
| 10 | +<pre> |
| 11 | +<strong>Input:</strong> candies = [2,3,5,1,3], extraCandies = 3 |
| 12 | +<strong>Output:</strong> [true,true,true,false,true] |
| 13 | +<strong>Explanation:</strong> If you give all extraCandies to: |
| 14 | +- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids. |
| 15 | +- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids. |
| 16 | +- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids. |
| 17 | +- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids. |
| 18 | +- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids. |
| 19 | +</pre> |
| 20 | + |
| 21 | +<p><strong class="example">Example 2:</strong></p> |
| 22 | + |
| 23 | +<pre> |
| 24 | +<strong>Input:</strong> candies = [4,2,1,1,2], extraCandies = 1 |
| 25 | +<strong>Output:</strong> [true,false,false,false,false] |
| 26 | +<strong>Explanation:</strong> There is only 1 extra candy. |
| 27 | +Kid 1 will always have the greatest number of candies, even if a different kid is given the extra candy. |
| 28 | +</pre> |
| 29 | + |
| 30 | +<p><strong class="example">Example 3:</strong></p> |
| 31 | + |
| 32 | +<pre> |
| 33 | +<strong>Input:</strong> candies = [12,1,12], extraCandies = 10 |
| 34 | +<strong>Output:</strong> [true,false,true] |
| 35 | +</pre> |
| 36 | + |
| 37 | +<p> </p> |
| 38 | +<p><strong>Constraints:</strong></p> |
| 39 | + |
| 40 | +<ul> |
| 41 | + <li><code>n == candies.length</code></li> |
| 42 | + <li><code>2 <= n <= 100</code></li> |
| 43 | + <li><code>1 <= candies[i] <= 100</code></li> |
| 44 | + <li><code>1 <= extraCandies <= 50</code></li> |
| 45 | +</ul> |
0 commit comments