add solution for determining which kids can have the most candies

This commit is contained in:
bobbert committed 2026-05-06 18:40:14 +01:00
1 parent 5fadd8b6e7
commit ad9dad2f8b
3 files changed
+25 -9

No files matched your search

@@ -0,0 +1,25 @@
class Solution {
public:
vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {
int csize = candies.size();
int i = 0;
int current;
int max = *std::max_element(candies.begin(), candies.end());
vector<bool> kids;
for (; i < csize; i++)
{
current = candies[i] + extraCandies;
if (max <= current)
{
kids.push_back(true);
}
else
{
kids.push_back(false);
}
}
return kids;
}
};