Skip to main content

1431.js

/** ------------------------------------------------------------------------------
*
* 2023-04-17
* 1431. Kids With the Greatest Number of Candies
* https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/
*
------------------------------------------------------------------------------ */
var kidsWithCandies = function (candies, extraCandies) {
const max = Math.max(...candies);
return candies.map((candy) => candy + extraCandies >= max);
};

console.log(kidsWithCandies([4, 2, 1, 1, 2], 1));