【leetcode】拥有最多糖果的孩子

 

bool* kidsWithCandies(int* candies, int candiesSize, int extraCandies, int* returnSize){
    int max=0,i;
    bool* arr = (bool*)malloc(candiesSize);
    for (i=0; i<candiesSize; i++)
    {
        if (candies[i]>max) max=candies[i];
    }
    for (i=0; i<candiesSize; i++)
    {
        arr[i] = (candies[i] + extraCandies >= max)? true : false;
    }
    *returnSize=candiesSize;
    return arr;
}

 

posted @ 2020-09-24 10:43  温暖了寂寞  阅读(102)  评论(0编辑  收藏  举报