class Solution {
public:
vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {
int m = candies.size();
vector<bool> res(m, false);
auto max_it = max_element(candies.begin(), candies.end());
int max = *max_it;
for (int i = 0; i < m; i++){
if (candies[i] + extraCandies < max) {
res[i] = false;
} else {
res[i] = true;
}
}
return res;
}
};
拥有最多糖果的孩子-数组1431-c++
最新推荐文章于 2024-05-23 15:18:15 发布