leetcode-1431. 拥有最多糖果的孩子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Solution {
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
int max = Integer.MIN_VALUE;
int n = candies.length;
for (int i = 0; i < n; i++) {
max = Math.max(max, candies[i]);
}

List<Boolean> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
if (candies[i] + extraCandies >= max) {
list.add(true);
}else {
list.add(false);
}
}
return list;
}
}