-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
数组
var kidsWithCandies = function(candies, extraCandies) {
const result = [];
// 先求最大值
let max = Number.MIN_VALUE;
for (let i = 0; i < candies.length; i++) {
max = Math.max(max, candies[i]);
}
// 再将每一项加上extraCandies后与最大值比较
for (let i = 0; i < candies.length; i++) {
result.push(candies[i] + extraCandies >= max);
}
return result;
};