Kids With the Greatest Number of Candies LeetCode solution in C++
1class Solution {2public:3vector<bool> kidsWithCandies(vector<int> &candies, int extraCandies) {4vector<bool> ans;5int i = 0, size, max = 0;6size = candies.size();7for (i = 0; i < size; i++) {8if (candies[i] > max) max = candies[i];9}10for (i = 0; i < size; i++) {11if (candies[i] + extraCandies >= max) {12ans.push_back(true);13} else14ans.push_back(false);15}16return ans;17}18};