반응형
Problem
이번 문제는 캔디갯수를 가진 배열 candies 와 , 더할 캔디 extraCandies를 주고
candies 각 캔디 갯수에 extraCandies를 더한값이 candies의 최대 값이면 True, 아니면 False로 바꾸어 반환한다
나의 풀이
class Solution:
def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]:
return [i+extraCandies>=max(candies) for i in candies]
i+extraCandies 가 candies의 최대값과 크거나 같으면 True , 아니면 False 가 나오게 문제를 풀고
리스트 컴프리헨션을 사용했다
반응형
'Python > algorithm' 카테고리의 다른 글
[Leetcode] 1365. How Many Numbers Are Smaller Than the Current Number (1) | 2023.01.05 |
---|---|
[Leetcode] 1281. Subtract the Product and Sum of Digits of an Integer (2) | 2023.01.04 |
[Leetcode] 2413. Smallest Even Multiple (1) | 2022.12.31 |
[Leetcode] 1603. Design Parking System (1) | 2022.12.30 |
[Leetcode] 2114. Maximum Number of Words Found in Sentences (0) | 2022.12.29 |