https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/
Kids With the Greatest Number of Candies - LeetCode
Can you solve this real interview question? Kids With the Greatest Number of Candies - There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandie
leetcode.com
1
2
3
4
5
6
7
8
9
10
11
|
class Solution:
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
my_max = max(candies)
answer = []
for candy in candies:
if candy + extraCandies >= my_max:
answer.append(True)
else:
answer.append(False)
return answer
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2652. Sum Multiples (0) | 2023.05.16 |
---|---|
백준 27959 초코바 (0) | 2023.04.25 |
백준 27889 특별한 학교 이름 (0) | 2023.04.04 |
leetcode 2348. Number of Zero-Filled Subarrays (0) | 2023.03.21 |
leetcode 1009. Complement of Base 10 Integer (0) | 2023.03.20 |
댓글