1431. Kids With the Greatest Number of Candies 發表於 2023-12-21 | 分類於 leetcode problemsolution12345678910111213class Solution {public: vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) { int n = candies.size(); int mx = *max_element(candies.begin(), candies.end()); vector<bool> ret(n, false); for(int i =0;i<n;++i) { ret[i] = candies[i]+extraCandies >= mx? true:false; } return ret; }}; analysis time complexity O(n) space complexity O(n)