one line of code at a time

[leetcode] 1432. Kids With the Greatest Number of Candies 파이썬 코드 본문

leetcode

[leetcode] 1432. Kids With the Greatest Number of Candies 파이썬 코드

oloc 2024. 8. 12. 05:57

1431. Kids With the Greatest Number of Candies

 

https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/

 

class Solution(object):
    def kidsWithCandies(self, candies, extraCandies):
        maxC = max(candies) # O(n)
        result = []
        for c in candies:
            if c + extraCandies >= maxC:
                result.append(True)
            else:
                result.append(False)

        return result