Kids With the Greatest Number of Candies LeetCode solution in C++

1
class Solution {
2
public:
3
vector<bool> kidsWithCandies(vector<int> &candies, int extraCandies) {
4
vector<bool> ans;
5
int i = 0, size, max = 0;
6
size = candies.size();
7
for (i = 0; i < size; i++) {
8
if (candies[i] > max) max = candies[i];
9
}
10
for (i = 0; i < size; i++) {
11
if (candies[i] + extraCandies >= max) {
12
ans.push_back(true);
13
} else
14
ans.push_back(false);
15
}
16
return ans;
17
}
18
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0