Leetcode 1431. Kids With the Greatest Number of Candies [Python]

class Solution:
    def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
        res= []
        maxcan = max(candies)
        for index, num in enumerate(candies):
            if num +  extraCandies>= maxcan:
                res.append(True)
            else:
                res.append(False)
        return res

 

你可能感兴趣的:(Leetcode学习记录)