Skip to content
thesarfo

Reference

Kids With the Greatest Number of Candies

Checking whether giving each kid all the extra candies would tie or beat the current maximum.

views 0

For each kid, would giving them all extraCandies make them tied for (or exceed) the current max? (LeetCode 1431)

def kidsWithCandies(candies, extraCandies):
max_candies = max(candies)
result = []
for candy in candies:
result.append(candy + extraCandies >= max_candies)
return result

Time: O(n). Space: O(n) for the result array.