LeetCode - Problems - Algorithms - 1431. Kids With the Greatest Number of Candies
Problem Description
Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.
For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them.
Notice that multiple kids can have the greatest number of candies.
Example:
Constraints:
My Solution (Python)
class Solution:
def kidsWithCandies(self, candies, extraCandies):
Maximum_Candies = max(candies)
answers = []
for c in candies:
if c + extraCandies >= Maximum_Candies:
answers.append(True)
else:
answers.append(False)
return answers
'Problem solving > Algorithms' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode] 1365. How Many Numbers Are Smaller Than the Current Number (Python) (0) | 2021.01.10 |
---|---|
[LeetCode] 1108. Defanging an IP Address (Python) (0) | 2021.01.10 |
[LeetCode] 1672. Richest Customer Wealth (Python) (0) | 2021.01.09 |
[LeetCode] 1480. Running Sum of 1d Array (Python) (0) | 2021.01.09 |
An array of divisible numbers (๋๋์ด ๋จ์ด์ง๋ ์ซ์ ๋ฐฐ์ด) (0) | 2020.09.10 |