java.lang.Object
g1401_1500.s1431_kids_with_the_greatest_number_of_candies.Solution

public class Solution extends Object
1431 - Kids With the Greatest Number of Candies.<p>Easy</p> <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> <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__, or</em> <code>false</code> <em>otherwise</em>.</p> <p>Note that <strong>multiple</strong> kids can have the <strong>greatest</strong> number of candies.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> candies = [2,3,5,1,3], extraCandies = 3</p> <p><strong>Output:</strong> [true,true,true,false,true]</p> <p><strong>Explanation:</strong> If you give all extraCandies to:</p> <ul> <li>Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.</li> <li>Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.</li> <li>Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.</li> <li>Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.</li> <li>Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.</li> </ul> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> candies = [4,2,1,1,2], extraCandies = 1</p> <p><strong>Output:</strong> [true,false,false,false,false]</p> <p><strong>Explanation:</strong> There is only 1 extra candy. Kid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> candies = [12,1,12], extraCandies = 10</p> <p><strong>Output:</strong> [true,false,true]</p> <p><strong>Constraints:</strong></p> <ul> <li><code>n == candies.length</code></li> <li><code>2 <= n <= 100</code></li> <li><code>1 <= candies[i] <= 100</code></li> <li><code>1 <= extraCandies <= 50</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • kidsWithCandies

      public List<Boolean> kidsWithCandies(int[] candies, int extraCandies)