There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith 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 ith 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.
How do I solve it
Breakdown:
Save the max value of the array into a variable.
In a for loop, check if the current candies array index value plus the extraCandies is less than or equal to the max.
What is this problem
How do I solve it
Breakdown:
max
value of the array into a variable.for
loop, check if the currentcandies
array index value plus theextraCandies
is less than or equal to themax
.true
is added to thelist
.false
is added.Resources
None.