Easy
Kids With the Greatest Number of Candies — Python
Full explanation · Time O(n) · Space O(1)
# Time: O(n)
# Space: O(1)
class Solution(object):
def kidsWithCandies(self, candies, extraCandies):
"""
:type candies: List[int]
:type extraCandies: int
:rtype: List[bool]
"""
max_num = max(candies)
return [x + extraCandies >= max_num for x in candies]