[LeetCode] 1431. Kids With the Greatest Number of Candies

0

LeetCode

목록 보기
48/58
post-thumbnail

[LeetCode] 1431. Kids With the Greatest Number of Candies

풀이

class Solution {
public:
    vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) {
        int maxCandy = 0;
        for(int i = 0; i<candies.size(); ++i) maxCandy = max(maxCandy, candies[i]);

        vector<bool> answer = vector<bool>();
        for(int i = 0; i<candies.size(); ++i) answer.push_back(candies[i] + extraCandies >= maxCandy);
        return answer;
    }
};
profile
Be able to be vulnerable, in search of truth

0개의 댓글