one line of code at a time
[leetcode] 1432. Kids With the Greatest Number of Candies 파이썬 코드 본문
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
'leetcode' 카테고리의 다른 글
| [leetcode] 151. Reverse Words in a String 파이썬 코드 (0) | 2024.08.12 |
|---|---|
| [leetcode] 345. Reverse Vowels of a String 파이썬 코드 (0) | 2024.08.12 |
| [leetcode] 21. Merge Two Sorted Lists 파이썬 코드 (0) | 2024.08.11 |
| [leetcode] 206. Reverse Linked List 파이썬 코드 (0) | 2024.08.11 |
| [leetcode] 215. Kth Largest Element in an Array 파이썬 코드 (0) | 2024.08.10 |