1431_拥有最多糖果的孩子
小于 1 分钟
1431_拥有最多糖果的孩子简单
class Solution {
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
List<Boolean> res = new ArrayList<>();
int max = 0;
for (int candy : candies) {
if (candy > max) max = candy;
}
for (int candy : candies) {
if (candy + extraCandies >= max) {
res.add(true);
} else {
res.add(false);
}
}
return res;
}
}
Powered by Waline v2.15.5