Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 437 Bytes

1431. Kids With the Greatest Number of Candies.md

File metadata and controls

17 lines (15 loc) · 437 Bytes
class Solution {
public:
    vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {

        vector<bool>result;
        int maxElement = *max_element(candies.begin(), candies.end()); 

        for(int i = 0; i<candies.size(); i++)
        {
            if(candies[i] + extraCandies >= maxElement) result.push_back(true);
            else result.push_back(false);    
        }
        return result;
    }
};