Determine which kids can end up with the greatest number of candies after receiving extra candies.
You are given an array candies, where candies[i] is the number of candies the -th kid has, and an integer extraCandies.
For each kid, decide whether that kid could have the greatest number of candies among all kids after receiving all of the extra candies. The extra candies can be given entirely to any one kid.
Return a list of boolean values where the -th value is true if the -th kid can have the greatest number of candies after receiving extraCandies, otherwise false.
A kid is considered to have the greatest number of candies if their candy count is at least as large as every other kid's candy count.
candies: an array of integersextraCandies: an integerThe input represents one test case.
candies.Example 1
Input
candies = [2,3,5,1,3], extraCandies = 3
Output
[true,true,true,false,true]
Explanation
If a kid receives 3 extra candies, their final count becomes [5,6,8,4,6]. Kids 0, 1, 2, and 4 can reach at least the maximum count of the original group.
Example 2
Input
candies = [4,2,1,1,2], extraCandies = 1
Output
[true,false,false,false,false]
Explanation
The maximum current count is 4. Only the first kid can still have the greatest number after receiving 1 extra candy.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.