给出每个人拥有的candy数量和extracandy,输出每个人手中的candy加上extracandy是否能成为candy最多的人,水题
1 #1431
2 #Runtime: 23 ms (Beats 69.82%)
3 #Memory: 13.3 MB (Beats 70.98%)
4
5 class Solution(object):
6 def kidsWithCandies(self, candies, extraCandies):
7 """
8 :type candies: List[int]
9 :type extraCandies: int
10 :rtype: List[bool]
11 """
12 ans = []
13 mx = max(candies)
14 for i in candies:
15 if i + extraCandies >= mx:
16 ans.append(True)
17 else:
18 ans.append(False)
19 return ans