DEV Community
class Solution {
public:
vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {
int max_candies = *max_element(candies.begin(), candies.end());
for (int i = 0; i < candies.size(); i++) {
candies[i] = candies[i] + extraCandies >= max_candies;
}
vector<bool> result(candies.size());
transform(candies.begin(), candies.end(), result.begin(), [](int i) { return i == 1; });
return result;
}
};
leetcode
challenge
Here is the link for the problem:
https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/
For further actions, you may consider blocking this person and/or reporting abuse
Read next
1. Designing A Microservice Architecture: Microservice vs Monolith
Ashutosh Sahu -
Creating a User in Unraid for Secure Access
John Ajera -
Creating a Windows 10 VM in Unraid
John Ajera -
Full Salesforce Oracle Integration Guide
Dorian Sabitov -
Top comments (0)