You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**[⬆ Back to Top](#javascript-coding-challenges-for-beginners)**
1409
+
1410
+
## 43. Kids With the Greatest Number of Candies
1411
+
1412
+
Given an array `candies` where `candies[i]` represents the number of candies that the `i`th kid has, and an integer `extraCandies`, write a function that for each kid checks if he/she would have the greatest number of candies in the group if they were given `extraCandies`. Note that multiple kids can have the greatest number of candies.
1413
+
For example,
1414
+
1415
+
```
1416
+
Input: candies = [2,3,5,1,3], extraCandies = 3
1417
+
Output: [true,true,true,false,true]
1418
+
1419
+
Explanation:
1420
+
- Kid 1 has 2 candies and if he or she receives all extra candies (3) will have 5 candies --- the greatest number of candies among the kids.
1421
+
- Kid 2 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids.
1422
+
- Kid 3 has 5 candies and this is already the greatest number of candies among the kids.
1423
+
- Kid 4 has 1 candy and even if he or she receives all extra candies will only have 4 candies.
1424
+
- Kid 5 has 3 candies and if he or she receives at least 2 extra candies will have the greatest number of candies among the kids.
0 commit comments