mirror of
https://github.com/mudabbir-ahmad/Leet-Code-prog.git
synced 2026-10-08 02:30:21 +00:00
25 lines
705 B
C++
25 lines
705 B
C++
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()); // needs the *std to dereference the iterator returned by max_element (From algo library. Gets max val from the vector)
|
|
|
|
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;
|
|
}
|
|
}; |