JuniorArray
Kids With the Greatest Number of Candies
There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the i^th kid has, and an integer extraCandies, denoting the number of extra candies that you have.
Return a boolean array result of length n, where result[i] is true if, after giving the i^th kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.
Note that multiple kids can have the greatest number of candies.
Example 1
Input
candies = [2,3,5,1,3], extraCandies = 3Output
[true,true,true,false,true]Giving all 3 extra candies to kids 1, 2, 3, and 5 lets each have the greatest number of candies, while kid 4 would not.
Example 2
Input
candies = [4,2,1,1,2], extraCandies = 1Output
[true,false,false,false,false]With only 1 extra candy, kid 1 will always have the greatest number of candies even if another kid receives the extra candy.
Constraints
n == candies.length2 <= n <= 1001 <= candies[i] <= 1001 <= extraCandies <= 50